diff options
author | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-01-12 11:06:11 +0000 |
---|---|---|
committer | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-01-12 11:06:11 +0000 |
commit | ebbd973a8a47a39f1bad1f302ed89212487c70e1 (patch) | |
tree | 812a7d8a74fbb9682704bf5c613a003fb3765346 /crawl-ref/source/libw32c.cc | |
parent | e14489b93f70d37f29d446208938b0bdc15e00f5 (diff) | |
download | crawl-ref-ebbd973a8a47a39f1bad1f302ed89212487c70e1.tar.gz crawl-ref-ebbd973a8a47a39f1bad1f302ed89212487c70e1.zip |
Add message buffer scrolling on Windows.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@839 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/libw32c.cc')
-rw-r--r-- | crawl-ref/source/libw32c.cc | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/crawl-ref/source/libw32c.cc b/crawl-ref/source/libw32c.cc index 4e778b7aab..dea7c01fb9 100644 --- a/crawl-ref/source/libw32c.cc +++ b/crawl-ref/source/libw32c.cc @@ -550,6 +550,87 @@ void textcolor(int c) current_color = c; } +void clear_message_window() +{ + PCHAR_INFO pci = screen + SCREENINDEX(0, VIEW_EY); + const int ncols = get_number_of_cols(); + for (int x = 0; x < ncols; x++) + { + for (int y = 0; y < get_message_window_height(); y++) + { + pci->Char.AsciiChar = ' '; + pci->Attributes = 0; + pci++; + } + } + + COORD source; + SMALL_RECT target; + + source.X = 0; + source.Y = VIEW_EY; + target.Left = 0; + target.Top = VIEW_EY; + target.Right = get_number_of_cols() - 1; + target.Bottom = get_number_of_lines() - 1; + + WriteConsoleOutput(outbuf, screen, screensize, source, &target); +} + +extern int get_message_window_height(); +static void scroll_message_buffer() +{ + memmove( screen + SCREENINDEX(0, VIEW_EY), + screen + SCREENINDEX(0, VIEW_EY + 1), + get_message_window_height() * get_number_of_cols() + * sizeof(*screen) ); +} + +static void scroll_message_window() +{ + SMALL_RECT scroll_rectangle, clip_rectangle; + scroll_rectangle.Left = 0; + scroll_rectangle.Top = VIEW_EY + 1; + scroll_rectangle.Right = get_number_of_cols() - 1; + scroll_rectangle.Bottom = get_number_of_lines() - 1; + + clip_rectangle = scroll_rectangle; + clip_rectangle.Top = VIEW_EY; + + COORD new_origin; + new_origin.X = 0; + new_origin.Y = VIEW_EY; + + CHAR_INFO fill; + fill.Char.AsciiChar = ' '; + fill.Attributes = WIN32COLOR(LIGHTGREY); + + ::ScrollConsoleScreenBuffer( + outbuf, &scroll_rectangle, &clip_rectangle, + new_origin, &fill); + + scroll_message_buffer(); + + // Cursor also scrolls up so prompts don't look brain-damaged. + if (wherey() == get_number_of_lines()) + gotoxy(wherex(), wherey() - 1); +} + +void message_out(int which_line, int colour, const char *s, int firstcol, + bool newline) +{ + if (!firstcol) + firstcol = Options.delay_message_clear? 2 : 1; + + gotoxy(firstcol, which_line + VIEW_EY + 1); + textcolor(colour); + + cprintf("%s", s); + + if (newline && which_line == get_message_window_height() - 1) + scroll_message_window(); +} + static void cprintf_aux(const char *s) { // early out -- not initted yet |