about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2012-02-18 21:02:51 +0000
committerJames Booth <boothj5@gmail.com>2012-02-18 21:02:51 +0000
commit7db2da6d11bb6ec5dd8703658898818b2a8eb0eb (patch)
treed5371b9994a618c91d147206e3b3c4d04f263b9e
parentd0f9998820d8c822e0ad2dc31729bd64b9c48330 (diff)
downloadprofani-tty-7db2da6d11bb6ec5dd8703658898818b2a8eb0eb.tar.gz
UI tweaks
-rw-r--r--main.c7
-rw-r--r--status_bar.c30
-rw-r--r--title_bar.c27
-rw-r--r--windows.c21
4 files changed, 54 insertions, 31 deletions
diff --git a/main.c b/main.c
index 2d9c44b7..50a9f1a5 100644
--- a/main.c
+++ b/main.c
@@ -4,13 +4,14 @@
 
 int main(void)
 {   
-    int exit_status = LOGIN_FAIL;
+    int exit_status;
+    
     log_init();
     gui_init();
 
-    while (exit_status == LOGIN_FAIL) {
+    do { 
         exit_status = profanity_start();
-    }
+    } while (exit_status == LOGIN_FAIL);
     
     gui_close();
     log_close();
diff --git a/status_bar.c b/status_bar.c
index 66eb3f9a..0f98d481 100644
--- a/status_bar.c
+++ b/status_bar.c
@@ -14,7 +14,9 @@ void create_status_bar(void)
 
     status_bar = newwin(1, cols, rows-2, 0);
     wbkgd(status_bar, COLOR_PAIR(3));
+    wattron(status_bar, COLOR_PAIR(4));
     mvwprintw(status_bar, 0, cols - 29, _active);
+    wattroff(status_bar, COLOR_PAIR(4));
     wrefresh(status_bar);
 }
 
@@ -28,27 +30,27 @@ void status_bar_refresh(void)
 
 void status_bar_inactive(int win)
 {
-    _active[1 + ((win - 1) * 3)] = ' ';
-    if (win == 9)
-        _active[1 + ((win -1) * 3)] = ' ';
-        
+    int active_pos = 1 + ((win -1) * 3);
+
     int rows, cols;
     getmaxyx(stdscr, rows, cols);
-    mvwprintw(status_bar, 0, cols - 29, _active);
+ 
+    mvwaddch(status_bar, 0, cols - 29 + active_pos, ' ');
+    if (win == 9)
+        mvwaddch(status_bar, 0, cols - 29 + active_pos + 1, ' ');
 }
 
 void status_bar_active(int win)
 {
-    if (win < 9) {
-        _active[1 + ((win -1) * 3)] = (char)( ((int)'0') + (win + 1));
-    } else {
-        _active[25] = '1';
-        _active[26] = '0';
-    }
-    
+    int active_pos = 1 + ((win -1) * 3);
+
     int rows, cols;
     getmaxyx(stdscr, rows, cols);
-    mvwprintw(status_bar, 0, cols - 29, _active);
+ 
+    if (win < 9)
+        mvwprintw(status_bar, 0, cols - 29 + active_pos, "%d", win+1);
+    else
+        mvwprintw(status_bar, 0, cols - 29 + active_pos, "10");
 }
 
 void status_bar_get_password(void)
@@ -67,7 +69,9 @@ void status_bar_clear(void)
 
     int rows, cols;
     getmaxyx(stdscr, rows, cols);
+    wattron(status_bar, COLOR_PAIR(4));
     mvwprintw(status_bar, 0, cols - 29, _active);
+    wattroff(status_bar, COLOR_PAIR(4));
 }
 
 static void _status_bar_update_time(void)
diff --git a/title_bar.c b/title_bar.c
index e19a5053..e26e2cd8 100644
--- a/title_bar.c
+++ b/title_bar.c
@@ -19,8 +19,16 @@ void title_bar_connected(void)
 {
     int rows, cols;
     getmaxyx(stdscr, rows, cols);
-   
-    mvwprintw(title_bar, 0, cols - 14, "[ ...online ]");
+
+    wattron(title_bar, COLOR_PAIR(4));
+    mvwaddch(title_bar, 0, cols - 14, '[');
+    wattroff(title_bar, COLOR_PAIR(4));
+
+    mvwprintw(title_bar, 0, cols - 13, " ...online ");
+    
+    wattron(title_bar, COLOR_PAIR(4));
+    mvwaddch(title_bar, 0, cols - 2, ']');
+    wattroff(title_bar, COLOR_PAIR(4));
 }
 
 void title_bar_disconnected(void)
@@ -28,7 +36,15 @@ void title_bar_disconnected(void)
     int rows, cols;
     getmaxyx(stdscr, rows, cols);
    
-    mvwprintw(title_bar, 0, cols - 14, "[ ..offline ]");
+    wattron(title_bar, COLOR_PAIR(4));
+    mvwaddch(title_bar, 0, cols - 14, '[');
+    wattroff(title_bar, COLOR_PAIR(4));
+    
+    mvwprintw(title_bar, 0, cols - 13, " ..offline ");
+    
+    wattron(title_bar, COLOR_PAIR(4));
+    mvwaddch(title_bar, 0, cols - 2, ']');
+    wattroff(title_bar, COLOR_PAIR(4));
 }
 
 void title_bar_refresh(void)
@@ -40,7 +56,10 @@ void title_bar_refresh(void)
 
 void title_bar_show(char *title)
 {
-    wclear(title_bar);
+    wmove(title_bar, 0, 0);
+    int i;
+    for (i = 0; i < 45; i++)
+        waddch(title_bar, ' ');
     mvwprintw(title_bar, 0, 0, " %s", title);
 }
 
diff --git a/windows.c b/windows.c
index fb94cbbc..ea6c5b03 100644
--- a/windows.c
+++ b/windows.c
@@ -15,16 +15,15 @@ void gui_init(void)
     initscr();
     cbreak();
     keypad(stdscr, TRUE);
-    
-    start_color();
-    init_color(COLOR_WHITE, 1000, 1000, 1000);
-    init_pair(1, COLOR_WHITE, COLOR_BLACK);
-    init_pair(2, COLOR_GREEN, COLOR_BLACK);
-    init_color(COLOR_BLUE, 0, 0, 250);
-    init_pair(3, COLOR_WHITE, COLOR_BLUE);
 
-    attron(A_BOLD);
-    attron(COLOR_PAIR(1));
+    if (has_colors()) {    
+        start_color();
+        
+        init_pair(1, COLOR_WHITE, COLOR_BLACK);
+        init_pair(2, COLOR_GREEN, COLOR_BLACK);
+        init_pair(3, COLOR_WHITE, COLOR_BLUE);
+        init_pair(4, COLOR_CYAN, COLOR_BLUE);
+    }
 
     refresh();
 
@@ -60,7 +59,7 @@ void win_switch_to(int i)
     _curr_win = i;
 
     if (i == 0) {
-        title_bar_show("Profanity. Type /help for help information");
+        title_bar_show("Profanity. Type /help for help information.");
     } else {
         title_bar_show(_wins[i].from);
     }
@@ -77,7 +76,7 @@ void win_close_win(void)
     
     // go back to console window
     _curr_win = 0;
-    title_bar_show("Profanity. Type /help for help information");
+    title_bar_show("Profanity. Type /help for help information.");
 }
 
 int win_in_chat(void)
2019-03-12 18:56:55 -0700 committer Kartik Agaram <vc@akkartik.com> 2019-03-12 19:14:12 -0700 5001 - drop the :(scenario) DSL' href='/akkartik/mu/commit/subx/021byte_addressing.cc?h=main&id=4a943d4ed313eff001504c2b5c472266e86a38af'>4a943d4e ^
83c67014 ^
4a943d4e ^









6fc975eb ^




c442a5ad ^
6fc975eb ^
5c26afb1 ^
861418f0 ^
c442a5ad ^
9ee351f3 ^
861418f0 ^
c442a5ad ^
6fc975eb ^

861418f0 ^
4a943d4e ^




83c67014 ^
4a943d4e ^











2eb174d6 ^



73728ec6 ^
2eb174d6 ^
4a943d4e ^
eb45b315 ^
4a943d4e ^

83c67014 ^
4a943d4e ^


83c67014 ^
4a943d4e ^








2eb174d6 ^




c442a5ad ^
3c81c7db ^
2eb174d6 ^





5c26afb1 ^
9ee351f3 ^
c442a5ad ^
2eb174d6 ^

5c26afb1 ^





4c3a867b ^







5c26afb1 ^






30f844ee ^
5c26afb1 ^






30f844ee ^
5c26afb1 ^






30f844ee ^
5c26afb1 ^






30f844ee ^
5c26afb1 ^






30f844ee ^
5c26afb1 ^






30f844ee ^
5c26afb1 ^






30f844ee ^
5c26afb1 ^






30f844ee ^
5c26afb1 ^






30f844ee ^
5c26afb1 ^






30f844ee ^
5c26afb1 ^

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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272