Mercurial > ~mikael > mcabber > hg
comparison mcabber/mcabber/screen.c @ 2231:387cea2a1a81
Fix resizing with --enable-sigwinch
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Sun, 15 Nov 2015 17:03:41 +0100 |
parents | c1eb68306520 |
children | 44bb9a033407 |
comparison
equal
deleted
inserted
replaced
2230:f5659f0f9db8 | 2231:387cea2a1a81 |
---|---|
1862 new_chatwidth = maxX - Roster_Width - scr_getprefixwidth(); | 1862 new_chatwidth = maxX - Roster_Width - scr_getprefixwidth(); |
1863 if (new_chatwidth != prev_chatwidth) | 1863 if (new_chatwidth != prev_chatwidth) |
1864 hbuf_rebuild(&wbp->bd->hbuf, new_chatwidth); | 1864 hbuf_rebuild(&wbp->bd->hbuf, new_chatwidth); |
1865 } | 1865 } |
1866 | 1866 |
1867 // scr_Resize() | 1867 // scr_resize() |
1868 // Function called when the window is resized. | 1868 // Function called when the window is resized. |
1869 // - Resize windows | 1869 // - Resize windows |
1870 // - Rewrap lines in each buddy buffer | 1870 // - Rewrap lines in each buddy buffer |
1871 void scr_Resize(void) | 1871 void scr_resize(void) |
1872 { | 1872 { |
1873 struct dimensions dim; | 1873 struct dimensions dim; |
1874 | 1874 |
1875 // First, update the global variables | 1875 // First, update the global variables |
1876 getmaxyx(stdscr, maxY, maxX); | 1876 getmaxyx(stdscr, maxY, maxX); |
1900 | 1900 |
1901 // Refresh current buddy window | 1901 // Refresh current buddy window |
1902 if (chatmode) | 1902 if (chatmode) |
1903 scr_show_buddy_window(); | 1903 scr_show_buddy_window(); |
1904 } | 1904 } |
1905 | |
1906 #ifdef USE_SIGWINCH | |
1907 void sigwinch_resize(void) | |
1908 { | |
1909 struct winsize size; | |
1910 if (ioctl(STDIN_FILENO, TIOCGWINSZ, &size) != -1) | |
1911 resizeterm(size.ws_row, size.ws_col); | |
1912 scr_resize(); | |
1913 } | |
1914 #endif | |
1905 | 1915 |
1906 // scr_update_chat_status(forceupdate) | 1916 // scr_update_chat_status(forceupdate) |
1907 // Redraw the buddy status bar. | 1917 // Redraw the buddy status bar. |
1908 // Set forceupdate to TRUE if update_panels() must be called. | 1918 // Set forceupdate to TRUE if update_panels() must be called. |
1909 void scr_update_chat_status(int forceupdate) | 1919 void scr_update_chat_status(int forceupdate) |
2305 else | 2315 else |
2306 roster_hidden = !roster_hidden; | 2316 roster_hidden = !roster_hidden; |
2307 | 2317 |
2308 if (roster_hidden != old_roster_status) { | 2318 if (roster_hidden != old_roster_status) { |
2309 // Recalculate windows size and redraw | 2319 // Recalculate windows size and redraw |
2310 scr_Resize(); | 2320 scr_resize(); |
2311 redrawwin(stdscr); | 2321 redrawwin(stdscr); |
2312 } | 2322 } |
2313 } | 2323 } |
2314 | 2324 |
2315 static void scr_write_message(const char *bjid, const char *text, | 2325 static void scr_write_message(const char *bjid, const char *text, |
3773 void readline_refresh_screen(void) | 3783 void readline_refresh_screen(void) |
3774 { | 3784 { |
3775 scr_check_auto_away(TRUE); | 3785 scr_check_auto_away(TRUE); |
3776 keypad(inputWnd, TRUE); | 3786 keypad(inputWnd, TRUE); |
3777 parse_colors(); | 3787 parse_colors(); |
3778 scr_Resize(); | 3788 scr_resize(); |
3779 redrawwin(stdscr); | 3789 redrawwin(stdscr); |
3780 } | 3790 } |
3781 | 3791 |
3782 void readline_disable_chat_mode(guint show_roster) | 3792 void readline_disable_chat_mode(guint show_roster) |
3783 { | 3793 { |
4448 break; | 4458 break; |
4449 case 3: // Ctrl-C | 4459 case 3: // Ctrl-C |
4450 scr_handle_CtrlC(); | 4460 scr_handle_CtrlC(); |
4451 break; | 4461 break; |
4452 case KEY_RESIZE: | 4462 case KEY_RESIZE: |
4453 #ifdef USE_SIGWINCH | 4463 scr_resize(); |
4454 { | |
4455 struct winsize size; | |
4456 if (ioctl(STDIN_FILENO, TIOCGWINSZ, &size) != -1) | |
4457 resizeterm(size.ws_row, size.ws_col); | |
4458 } | |
4459 #endif | |
4460 scr_Resize(); | |
4461 break; | 4464 break; |
4462 default: | 4465 default: |
4463 display_char = TRUE; | 4466 display_char = TRUE; |
4464 } // switch | 4467 } // switch |
4465 | 4468 |