X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=OSX%2Fiostextclient.m;fp=OSX%2Fiostextclient.m;h=09c6298561b41493cb9faf8f7b5503f80c16510f;hb=6f5482d73adb0165c0130bb47d852644ab0c4869;hp=646436c323fcbcb1bb026353b0225e0ca4558291;hpb=c70f94f648d51bb4828193124f325fa52b0e57f3;p=xscreensaver diff --git a/OSX/iostextclient.m b/OSX/iostextclient.m index 646436c3..09c62985 100644 --- a/OSX/iostextclient.m +++ b/OSX/iostextclient.m @@ -38,15 +38,6 @@ struct text_data { }; -void -textclient_reshape (text_data *d, - int pix_w, int pix_h, - int char_w, int char_h) -{ - d->columns = char_w; -} - - text_data * textclient_open (Display *dpy) { @@ -405,6 +396,7 @@ wrap_text (char *body, int columns) { int col = 0, last_col = 0; char *last_space = 0; + if (! body) return; for (char *p = body; *p; p++) { if (*p == '\r' || *p == '\n' || *p == ' ' || *p == '\t') { if (col > columns && last_space) { @@ -425,6 +417,23 @@ wrap_text (char *body, int columns) } +static void +rewrap_text (char *body, int columns) +{ + if (! body) return; + for (char *p = body; *p; p++) { + if (*p == '\n') { + if (p[1] == '\n') + p++; + else + *p = ' '; + } + } + wrap_text (body, columns); +} + + + static void strip_backslashes (char *s) { @@ -553,4 +562,14 @@ textclient_putc (text_data *d, XKeyEvent *k) return False; } + +void +textclient_reshape (text_data *d, + int pix_w, int pix_h, + int char_w, int char_h) +{ + d->columns = char_w; + rewrap_text (d->buf, d->columns); +} + #endif /* USE_IPHONE -- whole file */