summaryrefslogtreecommitdiffstats
path: root/src/ui.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui.c')
-rw-r--r--src/ui.c35
1 files changed, 31 insertions, 4 deletions
diff --git a/src/ui.c b/src/ui.c
index df52ac2..e741335 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -33,7 +33,11 @@ int dc_ui_print_message (WINDOW * textwin, struct dc_message * msg2do) {
if (x); /* set but not used */
return 1;
}
-int dc_ui_processline (struct dc_thread_control * t, char * l, WINDOW * textwin) {
+struct dc_ui {
+ int maxy; /* max line of screen */
+ int maxx; /* max column of screen */
+};
+int dc_ui_processline (struct dc_thread_control * t, char * l, WINDOW * textwin, struct dc_ui ui) {
struct dc_client * c = t->clients[0];
/* first we trim spaces at the end */
int i = 0, j = 0, k = 0, m = 0, n = 0;
@@ -64,8 +68,19 @@ int dc_ui_processline (struct dc_thread_control * t, char * l, WINDOW * textwin)
DC_CUE(c, c->guilds_lock);
break;
}
- for (i = 0; i < c->guilds[j]->channels_sizeof; i++)
- DC_SIMPLEPRINT(textwin, 4, " %02d. %s - %s\n", i, c->guilds[j]->channels[i]->name, c->guilds[j]->channels[i]->topic);
+ for (i = 0; i < c->guilds[j]->channels_sizeof; i += 2) {
+ int y = 0;
+ int x = 0;
+ getyx(textwin, y, x);
+ DC_SIMPLEPRINT(textwin, 4, " %02d. %s - %s", i, c->guilds[j]->channels[i]->name, c->guilds[j]->channels[i]->topic);
+ if (c->guilds[j]->channels_sizeof-1 == i) {
+ DC_SIMPLEPRINT(textwin, 1, "\n");
+ break;
+ }
+ wmove(textwin, y, ui.maxx/2);
+ if (x); /* prevent unused warnings */
+ DC_SIMPLEPRINT(textwin, 7, " %02d. %s - %s\n", i+1, c->guilds[j]->channels[i+1]->name, c->guilds[j]->channels[i+1]->topic);
+ }
DC_CUE(c, c->guilds_lock);
break;
case 'j':
@@ -165,6 +180,7 @@ int dc_ui_thread (struct dc_thread_control * t) {
int ret, x, y;
wint_t ch;
struct dc_client * c = t->clients[0];
+ struct dc_ui ui;
initscr();
cbreak();
noecho();
@@ -177,8 +193,11 @@ int dc_ui_thread (struct dc_thread_control * t) {
init_pair(4, COLOR_GREEN, COLOR_BLACK);
init_pair(5, COLOR_CYAN, COLOR_BLACK);
init_pair(6, COLOR_BLACK, COLOR_CYAN);
+ init_pair(7, COLOR_MAGENTA, COLOR_BLACK);
keypad(stdscr, TRUE);
getmaxyx(stdscr, y, x); /* to je macro, zato y in x nista kazalca (;: */
+ ui.maxy = y;
+ ui.maxx = x;
WINDOW * textwin = subwin(stdscr, y-3, x, 0, 0);
WINDOW * formwin = subwin(stdscr, 2, x, y-2, 0);
scrollok(textwin, TRUE);
@@ -291,6 +310,13 @@ int dc_ui_thread (struct dc_thread_control * t) {
case KEY_SDC:
form_driver(form, REQ_CLR_FIELD);
break;
+ /* case KEY_NPAGE:
+ wscrl(textwin, 10);
+ break;
+ case KEY_PPAGE:
+ wscrl(textwin, -10);
+ break;
+ */ /* you wish! ncurses does not keep scrollback. i could use fancy features such as pads, but I'll just make a gui instd */
case 9: /* idk fucken keybd */
case KEY_STAB: /* switch to next channel for sending */
dc_null();
@@ -325,7 +351,7 @@ int dc_ui_thread (struct dc_thread_control * t) {
case 10:
form_driver(form, REQ_NEXT_FIELD);
form_driver(form, REQ_PREV_FIELD);
- if (dc_ui_processline(t, field_buffer(field[0], 0), textwin) > 0)
+ if (dc_ui_processline(t, field_buffer(field[0], 0), textwin, ui) > 0)
form_driver(form, REQ_CLR_FIELD);
pos_form_cursor(form);
updinforow++;
@@ -335,6 +361,7 @@ int dc_ui_thread (struct dc_thread_control * t) {
break;
}
wrefresh(formwin);
+ /* wrefresh(textwin); */
}
i++;
usleep(2500);