Mercurial > ~mikael > mcabber > hg
comparison mcabber/src/screen.c @ 515:180f0a6e4ac9
Log window's height can be set by the user
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Mon, 14 Nov 2005 15:29:03 +0100 |
parents | 979eb0fe2969 |
children | 9480a76471b6 |
comparison
equal
deleted
inserted
replaced
514:979eb0fe2969 | 515:180f0a6e4ac9 |
---|---|
39 #include "settings.h" | 39 #include "settings.h" |
40 #include "utils.h" | 40 #include "utils.h" |
41 #include "list.h" | 41 #include "list.h" |
42 | 42 |
43 #define window_entry(n) list_entry(n, window_entry_t, list) | 43 #define window_entry(n) list_entry(n, window_entry_t, list) |
44 | |
45 #define DEFAULT_LOG_WIN_HEIGHT (5+2) | |
46 #define CHAT_WIN_HEIGHT (maxY-1-Log_Win_Height) | |
47 | |
48 static unsigned short int Log_Win_Height; | |
44 | 49 |
45 static inline void check_offset(int); | 50 static inline void check_offset(int); |
46 | 51 |
47 LIST_HEAD(window_list); | 52 LIST_HEAD(window_list); |
48 | 53 |
197 } | 202 } |
198 } | 203 } |
199 | 204 |
200 void scr_InitCurses(void) | 205 void scr_InitCurses(void) |
201 { | 206 { |
207 int requested_lwh; | |
202 initscr(); | 208 initscr(); |
203 raw(); | 209 raw(); |
204 noecho(); | 210 noecho(); |
205 nonl(); | 211 nonl(); |
206 intrflush(stdscr, FALSE); | 212 intrflush(stdscr, FALSE); |
209 Curses = TRUE; | 215 Curses = TRUE; |
210 | 216 |
211 ParseColors(); | 217 ParseColors(); |
212 | 218 |
213 getmaxyx(stdscr, maxY, maxX); | 219 getmaxyx(stdscr, maxY, maxX); |
214 if (maxY < LOG_WIN_HEIGHT+2) | 220 Log_Win_Height = DEFAULT_LOG_WIN_HEIGHT; |
215 maxY = LOG_WIN_HEIGHT+2; | 221 |
222 requested_lwh = settings_opt_get_int("log_win_height"); | |
223 if (requested_lwh > 0) { | |
224 if (maxY > requested_lwh + 3) | |
225 Log_Win_Height = requested_lwh + 2; | |
226 else | |
227 Log_Win_Height = ((maxY > 5) ? (maxY - 2) : 3); | |
228 } else if (requested_lwh < 0) { | |
229 Log_Win_Height = 3; | |
230 } | |
231 | |
232 if (maxY < Log_Win_Height+2) { | |
233 if (maxY < 5) { | |
234 Log_Win_Height = 3; | |
235 maxY = Log_Win_Height+2; | |
236 } else { | |
237 Log_Win_Height = maxY - 2; | |
238 } | |
239 } | |
216 inputLine[0] = 0; | 240 inputLine[0] = 0; |
217 ptr_inputline = inputLine; | 241 ptr_inputline = inputLine; |
218 | 242 |
219 setlocale(LC_CTYPE, ""); | 243 setlocale(LC_CTYPE, ""); |
220 utf8_mode = (strcmp(nl_langinfo(CODESET), "UTF-8") == 0); | 244 utf8_mode = (strcmp(nl_langinfo(CODESET), "UTF-8") == 0); |
549 { | 573 { |
550 if (fullinit) { | 574 if (fullinit) { |
551 /* Create windows */ | 575 /* Create windows */ |
552 rosterWnd = newwin(CHAT_WIN_HEIGHT, ROSTER_WIDTH, 0, 0); | 576 rosterWnd = newwin(CHAT_WIN_HEIGHT, ROSTER_WIDTH, 0, 0); |
553 chatWnd = newwin(CHAT_WIN_HEIGHT, maxX - ROSTER_WIDTH, 0, ROSTER_WIDTH); | 577 chatWnd = newwin(CHAT_WIN_HEIGHT, maxX - ROSTER_WIDTH, 0, ROSTER_WIDTH); |
554 logWnd_border = newwin(LOG_WIN_HEIGHT, maxX, CHAT_WIN_HEIGHT, 0); | 578 logWnd_border = newwin(Log_Win_Height, maxX, CHAT_WIN_HEIGHT, 0); |
555 logWnd = newwin(LOG_WIN_HEIGHT-2, maxX-2, CHAT_WIN_HEIGHT+1, 1); | 579 logWnd = newwin(Log_Win_Height-2, maxX-2, CHAT_WIN_HEIGHT+1, 1); |
556 inputWnd = newwin(1, maxX, maxY-1, 0); | 580 inputWnd = newwin(1, maxX, maxY-1, 0); |
557 if (!rosterWnd || !chatWnd || !logWnd || !inputWnd) { | 581 if (!rosterWnd || !chatWnd || !logWnd || !inputWnd) { |
558 scr_TerminateCurses(); | 582 scr_TerminateCurses(); |
559 fprintf(stderr, "Cannot create windows!\n"); | 583 fprintf(stderr, "Cannot create windows!\n"); |
560 exit(EXIT_FAILURE); | 584 exit(EXIT_FAILURE); |
566 } else { | 590 } else { |
567 /* Resize windows */ | 591 /* Resize windows */ |
568 wresize(rosterWnd, CHAT_WIN_HEIGHT, ROSTER_WIDTH); | 592 wresize(rosterWnd, CHAT_WIN_HEIGHT, ROSTER_WIDTH); |
569 wresize(chatWnd, CHAT_WIN_HEIGHT, maxX - ROSTER_WIDTH); | 593 wresize(chatWnd, CHAT_WIN_HEIGHT, maxX - ROSTER_WIDTH); |
570 | 594 |
571 wresize(logWnd_border, LOG_WIN_HEIGHT, maxX); | 595 wresize(logWnd_border, Log_Win_Height, maxX); |
572 wresize(logWnd, LOG_WIN_HEIGHT-2, maxX-2); | 596 wresize(logWnd, Log_Win_Height-2, maxX-2); |
573 mvwin(logWnd_border, CHAT_WIN_HEIGHT, 0); | 597 mvwin(logWnd_border, CHAT_WIN_HEIGHT, 0); |
574 mvwin(logWnd, CHAT_WIN_HEIGHT+1, 1); | 598 mvwin(logWnd, CHAT_WIN_HEIGHT+1, 1); |
575 | 599 |
576 wresize(inputWnd, 1, maxX); | 600 wresize(inputWnd, 1, maxX); |
577 mvwin(inputWnd, maxY-1, 0); | 601 mvwin(inputWnd, maxY-1, 0); |
582 /* Draw/init windows */ | 606 /* Draw/init windows */ |
583 | 607 |
584 mvwprintw(chatWnd, 0, 0, "This is the status window"); | 608 mvwprintw(chatWnd, 0, 0, "This is the status window"); |
585 | 609 |
586 // - Draw/clear the log window | 610 // - Draw/clear the log window |
587 scr_draw_box(logWnd_border, 0, 0, LOG_WIN_HEIGHT, maxX, COLOR_GENERAL, 0, 0); | 611 scr_draw_box(logWnd_border, 0, 0, Log_Win_Height, maxX, COLOR_GENERAL, 0, 0); |
588 // Auto-scrolling in log window | 612 // Auto-scrolling in log window |
589 scrollok(logWnd, TRUE); | 613 scrollok(logWnd, TRUE); |
590 | 614 |
591 | 615 |
592 if (fullinit) { | 616 if (fullinit) { |
627 window_entry_t *search_entry; | 651 window_entry_t *search_entry; |
628 int x, y, lines, cols; | 652 int x, y, lines, cols; |
629 | 653 |
630 // First, update the global variables | 654 // First, update the global variables |
631 getmaxyx(stdscr, maxY, maxX); | 655 getmaxyx(stdscr, maxY, maxX); |
632 if (maxY < LOG_WIN_HEIGHT+2) | 656 if (maxY < Log_Win_Height+2) |
633 maxY = LOG_WIN_HEIGHT+2; | 657 maxY = Log_Win_Height+2; |
634 // Make sure the cursor stays inside the window | 658 // Make sure the cursor stays inside the window |
635 check_offset(0); | 659 check_offset(0); |
636 | 660 |
637 // Resize windows and update panels | 661 // Resize windows and update panels |
638 scr_DrawMainWindow(FALSE); | 662 scr_DrawMainWindow(FALSE); |