about summary refs log tree commit diff stats
path: root/src/ui
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-11-16 16:27:11 +0000
committerJames Booth <boothj5@gmail.com>2014-11-16 16:27:11 +0000
commit90dd1de91a6972bf82fb385dd277444ac5317484 (patch)
tree96c5dec7312c5dd02e9947d892fd1a8b0b05d876 /src/ui
parentcd855d3740c9fa0574bf15616754b359e4c9e1b1 (diff)
downloadprofani-tty-90dd1de91a6972bf82fb385dd277444ac5317484.tar.gz
Fixed indentation bug
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/window.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/src/ui/window.c b/src/ui/window.c
index 41590e44..59bcee86 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -641,31 +641,37 @@ _win_print(ProfWin *window, const char show_char, GDateTime *time,
 }
 
 static void
-_win_print_wrapped(WINDOW *win, const char * const message)
+_win_indent(WINDOW *win, int size)
 {
     int i = 0;
+    for (i = 0; i < size; i++) {
+        waddch(win, ' ');
+    }
+}
+
+static void
+_win_print_wrapped(WINDOW *win, const char * const message)
+{
     int linei = 0;
     int wordi = 0;
     char *word = malloc(strlen(message) + 1);
 
     char *time_pref = prefs_get_string(PREF_TIME);
-    int wrap_space = 0;
+    int indent = 0;
     if (g_strcmp0(time_pref, "minutes") == 0) {
-        wrap_space = 8;
+        indent = 8;
     } else if (g_strcmp0(time_pref, "seconds") == 0) {
-        wrap_space = 11;
+        indent = 11;
     }
     free(time_pref);
 
     while (message[linei] != '\0') {
         if (message[linei] == ' ') {
-            wprintw(win, " ");
+            waddch(win, ' ');
             linei++;
         } else if (message[linei] == '\n') {
             waddch(win, '\n');
-            for (i = 0; i < wrap_space; i++) {
-                waddch(win, ' ');
-            }
+            _win_indent(win, indent);
             linei++;
         } else {
             wordi = 0;
@@ -678,28 +684,22 @@ _win_print_wrapped(WINDOW *win, const char * const message)
             int maxx = getmaxx(win);
 
             // word larger than line
-            if (strlen(word) > (maxx - wrap_space)) {
+            if (strlen(word) > (maxx - indent)) {
                 int i;
                 for (i = 0; i < wordi; i++) {
                     curx = getcurx(win);
-                    if (curx < wrap_space) {
-                        for (i = 0; i < wrap_space; i++) {
-                            waddch(win, ' ');
-                        }
+                    if (curx < indent) {
+                        _win_indent(win, indent);
                     }
                     waddch(win, word[i]);
                 }
             } else {
                 if (curx + strlen(word) > maxx) {
                     waddch(win, '\n');
-                    for (i = 0; i < wrap_space; i++) {
-                        waddch(win, ' ');
-                    }
+                    _win_indent(win, indent);
                 }
-                if (curx < wrap_space) {
-                    for (i = 0; i < wrap_space; i++) {
-                        waddch(win, ' ');
-                    }
+                if (curx < indent) {
+                    _win_indent(win, indent);
                 }
                 wprintw(win, "%s", word);
             }