diff options
author | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-06-17 19:45:07 +0000 |
---|---|---|
committer | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-06-17 19:45:07 +0000 |
commit | b7516d279965cc139c24507688047172bb7a0f7f (patch) | |
tree | fbf8b141c74def2fbfe2fb343e457dad0ae24cb7 /crawl-ref/source/view.cc | |
parent | 23c5277317de657f8376d1b5f33144948a811a42 (diff) | |
download | crawl-ref-b7516d279965cc139c24507688047172bb7a0f7f.tar.gz crawl-ref-b7516d279965cc139c24507688047172bb7a0f7f.zip |
Basic SIGWINCH handling for Unix. Still needs to handle some cases (resizing
the term in the level-map doesn't work right, for instance).
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1593 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/view.cc')
-rw-r--r-- | crawl-ref/source/view.cc | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc index 1b34462ffb..fe384a5809 100644 --- a/crawl-ref/source/view.cc +++ b/crawl-ref/source/view.cc @@ -4131,11 +4131,10 @@ void crawl_view_geometry::init_geometry() termsz = coord_def( get_number_of_cols(), get_number_of_lines() ); // If the terminal is too small, exit with an error. - if (termsz.x < 80 || termsz.y < 24) + if ((termsz.x < 80 || termsz.y < 24) && !crawl_state.need_save) end(1, false, "Terminal too small (%d,%d), need at least (80,24)", termsz.x, termsz.y); - int freeheight = termsz.y - message_min_lines; // Make the viewport as tall as possible. @@ -4146,6 +4145,10 @@ void crawl_view_geometry::init_geometry() if (!(viewsz.y % 2)) --viewsz.y; + // If the view is too short, force it to minimum height. + if (viewsz.y < VIEW_MIN_HEIGHT) + viewsz.y = VIEW_MIN_HEIGHT; + // The message pane takes all lines not used by the viewport. msgp = coord_def(1, viewsz.y + 1); msgsz = coord_def(termsz.x, termsz.y - viewsz.y); @@ -4158,6 +4161,9 @@ void crawl_view_geometry::init_geometry() if (!(viewsz.x % 2)) --viewsz.x; + if (viewsz.x < VIEW_MIN_WIDTH) + viewsz.x = VIEW_MIN_WIDTH; + // The hud appears after the viewport + gutter. hudp = coord_def(viewsz.x + 1 + hud_min_gutter, 1); @@ -4174,3 +4180,19 @@ void crawl_view_geometry::init_geometry() init_view(); } + +//////////////////////////////////////////////////////////////////////////// +// Term resize handling (generic). + +void handle_terminal_resize(bool redraw) +{ + crawl_state.terminal_resized = false; + + if (crawl_state.terminal_resize_handler) + (*crawl_state.terminal_resize_handler)(); + else + crawl_view.init_geometry(); + + if (redraw) + redraw_screen(); +} |