lchat

A line oriented chat front end for ii.
git clone git://git.suckless.org/lchat
Log | Files | Refs

commit c12f5752c6768d3a218a071fe568721fba4f8875
parent 82f399cae0c9602a1527e4c0ee2d1e7c37a70770
Author: Jan Klemkow <j.klemkow@wemelug.de>
Date:   Sun, 15 Nov 2015 22:10:02 +0100

make bell optional

Diffstat:
lchat.1 | 4+++-
lchat.c | 11++++++++---
2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/lchat.1 b/lchat.1 @@ -6,7 +6,7 @@ .Nd line chat .Sh SYNOPSIS .Nm -.Op Fl eh +.Op Fl aeh .Op Fl n Ar lines .Op Fl p Ar prompt .Op Fl t Ar title @@ -32,6 +32,8 @@ path. The options are as follows: .Bl -tag -width Ds +.It Fl a +Turn off the bell on external line input. .It Fl e Allow to enter empty lines. .It Fl h diff --git a/lchat.c b/lchat.c @@ -68,7 +68,7 @@ line_output(struct slackline *sl, char *file) static void usage(void) { - fprintf(stderr, "lchar [-eh] [-n lines] [-p prompt] [-t title] [-i in]" + fprintf(stderr, "lchar [-aeh] [-n lines] [-p prompt] [-t title] [-i in]" " [-o out] [directory]\n"); exit(EXIT_FAILURE); } @@ -84,6 +84,7 @@ main(int argc, char *argv[]) int c; int ch; bool empty_line = false; + bool bell = true; size_t history_len = 5; char *prompt = ">"; size_t prompt_len = strlen(prompt); @@ -93,8 +94,11 @@ main(int argc, char *argv[]) char *out_file = NULL; FILE *tail_fh; - while ((ch = getopt(argc, argv, "n:i:eo:p:t:h")) != -1) { + while ((ch = getopt(argc, argv, "an:i:eo:p:t:h")) != -1) { switch (ch) { + case 'a': + bell = false; + break; case 'n': errno = 0; history_len = strtoull(optarg, NULL, 0); @@ -234,7 +238,8 @@ main(int argc, char *argv[]) err(EXIT_FAILURE, "read"); if (write(STDOUT_FILENO, buf, n) == -1) err(EXIT_FAILURE, "write"); - putchar('\a'); /* ring the bell on external input */ + if (bell) /* ring the bell on external input */ + putchar('\a'); } out: /* show current input line */