Skip to content

Commit 505e622

Browse files
authored
change -W to automatic wrap (#50)
* change -W to automatic wrap * address Codacy compliance
1 parent 757d5c8 commit 505e622

File tree

3 files changed

+26
-26
lines changed

3 files changed

+26
-26
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ make install
7272
Consult `man kirc` for a full list and explanation of available `kirc` arguments.
7373

7474
```shell
75-
kirc [-s hostname] [-p port] [-c channels] [-n nickname] [-r realname] [-u username] [-k password] [-a token] [-x command] [-w nick_width] [-W max_width] [-o logfile] [-e|v|V]
75+
kirc [-s hostname] [-p port] [-c channels] [-n nickname] [-r realname] [-u username] [-k password] [-a token] [-x command] [-w nick_width] [-o logfile] [-e|v|V]
7676
```
7777

7878
## Transport Layer Security (TLS) Support
@@ -161,4 +161,4 @@ Some users may experience abnormal *BACKSPACE* key press behavior, particularly
161161
## Contact
162162

163163
For any further questions or concerns, feel free to reach out to me, [mcpcpc](https://github.com/mcpcpc), on `#kirc`
164-
or `#kisslinux` channels of the _irc.freenode.org_ server.
164+
or `#kisslinux` channels of the *irc.freenode.org* server.

kirc.1

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ Specifies the PASS connection password
4444
.BI \-w " nick_width"
4545
Specifies max character width printed in the left column
4646
.TP
47-
.BI \-W " max_width"
48-
Specifies max printed with of the IRC stream
49-
.TP
5047
.BI \-x " command"
5148
Specifies additional commands to send to the host after initial connection.
5249
.TP

kirc.c

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,25 @@
1515

1616
#define VERSION "0.1.3"
1717

18-
#define MSG_MAX 512 /* guaranteed max message length */
19-
#define CHA_MAX 200 /* guaranteed max channel length */
20-
21-
static int conn; /* connection socket */
22-
static char chan_default[MSG_MAX]; /* default channel for PRIVMSG */
23-
static int verb = 0; /* verbose output (e.g. raw stream) */
24-
static int sasl = 0; /* SASL method (PLAIN=0, EXTERNAL=1) */
25-
static size_t cmax = 80; /* max number of chars per line */
26-
static size_t gutl = 20; /* max char width of left column */
27-
static char * host = "irc.freenode.org"; /* irc host address */
28-
static char * port = "6667"; /* server port */
29-
static char * chan = NULL; /* channel(s) */
30-
static char * nick = NULL; /* nickname */
31-
static char * pass = NULL; /* server password */
32-
static char * user = NULL; /* server user name */
33-
static char * auth = NULL; /* PLAIN SASL authentication token */
34-
static char * real = NULL; /* server user real name */
35-
static char * olog = NULL; /* log irc stream path */
36-
static char * inic = NULL; /* server command after connection */
18+
#define MSG_MAX 512 /* max message length */
19+
#define CHA_MAX 200 /* max channel length */
20+
21+
static unsigned short cmax; /* max printed line chars */
22+
static int conn; /* connection socket */
23+
static char chan_default[MSG_MAX]; /* default PRIVMSG channel */
24+
static int verb = 0; /* verbose output */
25+
static int sasl = 0; /* SASL method */
26+
static size_t gutl = 20; /* max printed nick chars */
27+
static char * host = "irc.freenode.org"; /* host address */
28+
static char * port = "6667"; /* port */
29+
static char * chan = NULL; /* channel(s) */
30+
static char * nick = NULL; /* nickname */
31+
static char * pass = NULL; /* password */
32+
static char * user = NULL; /* user name */
33+
static char * auth = NULL; /* PLAIN SASL token */
34+
static char * real = NULL; /* real name */
35+
static char * olog = NULL; /* chat log path*/
36+
static char * inic = NULL; /* additional server command */
3737

3838
static void
3939
log_append(char *str, char *path) {
@@ -280,7 +280,7 @@ main(int argc, char **argv) {
280280

281281
int cval;
282282

283-
while ((cval = getopt(argc, argv, "s:p:o:n:k:c:u:r:x:w:W:a:hevV")) != -1) {
283+
while ((cval = getopt(argc, argv, "s:p:o:n:k:c:u:r:x:w:a:hevV")) != -1) {
284284
switch (cval) {
285285
case 'V' : ++verb; break;
286286
case 'e' : ++sasl; break;
@@ -295,7 +295,6 @@ main(int argc, char **argv) {
295295
case 'c' : chan = optarg; break;
296296
case 'x' : inic = optarg; break;
297297
case 'w' : gutl = atoi(optarg); break;
298-
case 'W' : cmax = atoi(optarg); break;
299298
case 'v' : puts("kirc-" VERSION); break;
300299
case '?' : usage(); break;
301300
}
@@ -319,6 +318,8 @@ main(int argc, char **argv) {
319318
if (pass) raw("PASS %s\r\n", pass);
320319
if (inic) raw("%s\r\n", inic);
321320

321+
struct winsize window_dims;
322+
322323
struct pollfd fds[2];
323324
fds[0].fd = STDIN_FILENO;
324325
fds[1].fd = conn;
@@ -327,6 +328,8 @@ main(int argc, char **argv) {
327328

328329
for (;;) {
329330
int poll_res = poll(fds, 2, -1);
331+
ioctl(0, TIOCGWINSZ, &window_dims);
332+
cmax = window_dims.ws_col;
330333
if (poll_res != -1) {
331334
if (fds[0].revents & POLLIN) {
332335
handle_user_input();

0 commit comments

Comments
 (0)