Skip to content

Commit ded0e58

Browse files
committed
fix printw behavior, new gutl=20
1 parent 0635d02 commit ded0e58

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

kirc.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
static int conn; /* connection socket */
2424
static int verb = 0; /* verbose output (e.g. raw stream) */
2525
static size_t cmax = 80; /* max number of chars per line */
26-
static size_t gutl = 10; /* max char width of left column */
26+
static size_t gutl = 20; /* max char width of left column */
2727
static char chan[CHA_MAX] = "kirc"; /* channel */
2828
static char * host = "irc.freenode.org"; /* irc host address */
2929
static char * port = "6667"; /* server port */
@@ -131,14 +131,14 @@ printw(const char *format, ...) {
131131

132132
for (i = 0; line[i] == ' '; ++i) putchar(line[i]);
133133

134-
spaceleft = cmax + gutl - (i - 1);
134+
spaceleft = cmax - (i - 1);
135135

136136
for(tok = strtok(&line[i], " "); tok != NULL; tok = strtok(NULL, " ")) {
137-
wordwidth = strlen(tok);
137+
wordwidth = strlen(tok) - 1;
138138

139139
if ((wordwidth + spacewidth) > spaceleft) {
140-
printf("\n%*.s%s ", (int) gutl + 1, "", tok);
141-
spaceleft = cmax - (gutl + 1 + wordwidth);
140+
printf("\n%*.s%s ", (int) gutl + 1, " ", tok);
141+
spaceleft = cmax - (gutl + 1 + wordwidth + spacewidth);
142142
} else {
143143
printf("%s ", tok);
144144
spaceleft = spaceleft - (wordwidth + spacewidth);

0 commit comments

Comments
 (0)