about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-11-08 21:03:28 +0000
committerJames Booth <boothj5@gmail.com>2014-11-08 21:03:28 +0000
commitecef8f79564d099c3f8a244acb3530411538ad69 (patch)
treedbcbf449144084182d08f0fc599ea319b25aef18
parentf1882439c2767f672b498388391b2a1b1d8d355f (diff)
downloadprofani-tty-ecef8f79564d099c3f8a244acb3530411538ad69.tar.gz
Print one word at a time
-rw-r--r--src/ui/window.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/src/ui/window.c b/src/ui/window.c
index 857a294c..7bb1e973 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -53,6 +53,7 @@
 
 static void _win_print(ProfWin *window, const char show_char, const char * const date_fmt,
     int flags, int attrs, const char * const from, const char * const message);
+static void _win_print_wrapped(WINDOW *win, const char * const message);
 
 
 ProfWin*
@@ -579,9 +580,10 @@ _win_print(ProfWin *window, const char show_char, const char * const date_fmt,
     wattron(window->win, attrs);
 
     if (flags & NO_EOL) {
-        wprintw(window->win, "%s", message+offset);
+        _win_print_wrapped(window->win, message+offset);
     } else {
-        wprintw(window->win, "%s\n", message+offset);
+        _win_print_wrapped(window->win, message+offset);
+        wprintw(window->win, "\n");
     }
 
     wattroff(window->win, attrs);
@@ -591,6 +593,30 @@ _win_print(ProfWin *window, const char show_char, const char * const date_fmt,
     }
 }
 
+static void
+_win_print_wrapped(WINDOW *win, const char * const message)
+{
+    int linei = 0;
+    int wordi = 0;
+    char *word = malloc(strlen(message) + 1);
+
+    while (message[linei] != '\0') {
+        if (message[linei] == ' ') {
+            wprintw(win, " ");
+            linei++;
+        } else {
+            wordi = 0;
+            while (message[linei] != ' ' && message[linei] != '\0') {
+                word[wordi++] = message[linei++];
+            }
+            word[wordi] = '\0';
+            wprintw(win, "%s", word);
+        }
+    }
+
+    free(word);
+}
+
 void
 win_redraw(ProfWin *window)
 {
62a244211024a8367332541c571621883c05bcce'>^
4a4a392d ^






2104d1a7 ^
b1635a5c ^
4a4a392d ^








8aeb85f0 ^
4a4a392d ^
2104d1a7 ^
4a4a392d ^
9a777801 ^
4a4a392d ^

2104d1a7 ^
4a4a392d ^



6070c23e ^
8aeb85f0 ^
4a4a392d ^





ec73ed12 ^
4a4a392d ^










b1635a5c ^
4a4a392d ^




b1635a5c ^
4a4a392d ^




3350c34a ^
4a4a392d ^
ec73ed12 ^
4a4a392d ^

8aeb85f0 ^
4a4a392d ^
8aeb85f0 ^
999c529c ^
ec73ed12 ^
999c529c ^

fa786ea7 ^
999c529c ^
9a777801 ^
999c529c ^



3350c34a ^
999c529c ^
ec73ed12 ^
999c529c ^



3350c34a ^
999c529c ^
ec73ed12 ^
999c529c ^

775f77c3 ^
999c529c ^



3350c34a ^
999c529c ^
ec73ed12 ^
999c529c ^







4a4a392d ^



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172