about summary refs log tree commit diff stats
path: root/src/ui/window.c
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-11-09 23:05:53 +0000
committerJames Booth <boothj5@gmail.com>2014-11-09 23:05:53 +0000
commit70501f5dbf1b8d80b80c7b24e0e6ab46921ba7dd (patch)
tree53d77b2fe77ef1c4e41ef9b7c9deeef197efa205 /src/ui/window.c
parentfbda2b41701ec61a9b72dbde91000ad95d597b9f (diff)
downloadprofani-tty-70501f5dbf1b8d80b80c7b24e0e6ab46921ba7dd.tar.gz
Wordwrap, handle words bigger than line space
Diffstat (limited to 'src/ui/window.c')
-rw-r--r--src/ui/window.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/ui/window.c b/src/ui/window.c
index 94c4cf2a..6f224a04 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -621,13 +621,25 @@ _win_print_wrapped(WINDOW *win, const char * const message)
             int curx = getcurx(win);
             int maxx = getmaxx(win);
 
-            if (curx + strlen(word) > maxx) {
-                wprintw(win, "\n           ");
-            }
-            if (curx < 11) {
-                wprintw(win, "           ");
+            // word larger than line
+            if (strlen(word) > (maxx - 11)) {
+                int i;
+                for (i = 0; i < wordi; i++) {
+                    curx = getcurx(win);
+                    if (curx < 11) {
+                        wprintw(win, "           ");
+                    }
+                    waddch(win, word[i]);
+                }
+            } else {
+                if (curx + strlen(word) > maxx) {
+                    wprintw(win, "\n           ");
+                }
+                if (curx < 11) {
+                    wprintw(win, "           ");
+                }
+                wprintw(win, "%s", word);
             }
-            wprintw(win, "%s", word);
         }
     }