reimplement window resizing
After get_wch() was dropped from the code resizing no longer worked, so reimplement it. Use a signal handler, and call the proper ncurses functions so that the internal variables are updated.
This commit is contained in:
		
							parent
							
								
									318c874dc6
								
							
						
					
					
						commit
						551e67c823
					
				| @ -27,6 +27,7 @@ struct ncdc_mainwindow_; | ||||
| typedef struct ncdc_mainwindow_ *ncdc_mainwindow_t; | ||||
| 
 | ||||
| ncdc_mainwindow_t ncdc_mainwindow_new(void); | ||||
| void ncdc_mainwindow_resize(ncdc_mainwindow_t n); | ||||
| 
 | ||||
| /* holy shit stains I am lazy
 | ||||
|  */ | ||||
|  | ||||
| @ -66,7 +66,6 @@ struct ncdc_mainwindow_ | ||||
|     int focus; | ||||
| }; | ||||
| 
 | ||||
| static void ncdc_mainwindow_resize(ncdc_mainwindow_t n); | ||||
| static void ncdc_mainwindow_update_focus(ncdc_mainwindow_t n); | ||||
| static bool ncdc_mainwindow_callback(ncdc_input_t i, wchar_t const *s, | ||||
|                                      size_t len, void *arg); | ||||
| @ -154,7 +153,7 @@ ncdc_mainwindow_callback(ncdc_input_t i, wchar_t const *s, | ||||
|     return ret; | ||||
| } | ||||
| 
 | ||||
| static void ncdc_mainwindow_resize(ncdc_mainwindow_t n) | ||||
| void ncdc_mainwindow_resize(ncdc_mainwindow_t n) | ||||
| { | ||||
|     n->guilds_h = LINES - 2; | ||||
|     n->guilds_w = (COLS / 4); | ||||
|  | ||||
| @ -86,6 +86,19 @@ static void cleanup(void) | ||||
|     dc_unref(mainwin); | ||||
| } | ||||
| 
 | ||||
| static void handle_winch(int sig) | ||||
| { | ||||
|     /* according to ncurses documentation you should call
 | ||||
|      * endwin(), followed by a refresh() to properly update | ||||
|      * curses | ||||
|      */ | ||||
|     endwin(); | ||||
|     refresh(); | ||||
|     clear(); | ||||
| 
 | ||||
|     ncdc_mainwindow_resize(mainwin); | ||||
| } | ||||
| 
 | ||||
| static void sighandler(int sig) | ||||
| { | ||||
|     exit_main(); | ||||
| @ -167,6 +180,7 @@ int main(int ac, char **av) | ||||
|     int ret = 0; | ||||
| 
 | ||||
|     signal(SIGINT, sighandler); | ||||
|     signal(SIGWINCH, handle_winch); | ||||
| 
 | ||||
|     if (getenv("HOME") == NULL) { | ||||
|         fprintf(stderr, "your environment doesn't contain HOME; pls fix\n"); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user