summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/libunix.cc
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-01-12 08:41:34 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-01-12 08:41:34 +0000
commit7a592cc1f6ccc109172b0653f0eb43fd8f1c40a2 (patch)
tree29667502b0de5bc7664f4b93b7693ed3236030f9 /crawl-ref/source/libunix.cc
parent4a36706dfc155fbf554767e537451a8a037b209b (diff)
downloadcrawl-ref-7a592cc1f6ccc109172b0653f0eb43fd8f1c40a2.tar.gz
crawl-ref-7a592cc1f6ccc109172b0653f0eb43fd8f1c40a2.zip
First steps towards making delay_message_clear useful. The intent is to use a
scrolling message window and show --more-- only when the message window is filled with new messages since the last mesclr (as suggested by Eidolos/doy on ##crawl). This currently works only on curses (breaks the DOS and Windows compiles), I'm working on fixing that. There are also some cursor glitches with prompts at the bottom of the message window that I need to fix. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@837 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/libunix.cc')
-rw-r--r--crawl-ref/source/libunix.cc71
1 files changed, 64 insertions, 7 deletions
diff --git a/crawl-ref/source/libunix.cc b/crawl-ref/source/libunix.cc
index a02ffbf7c4..55273b343f 100644
--- a/crawl-ref/source/libunix.cc
+++ b/crawl-ref/source/libunix.cc
@@ -70,6 +70,9 @@ int Character_Set = CHARACTER_SET;
short FG_COL = WHITE;
short BG_COL = BLACK;
+static int curs_fg_attr(int col);
+static int curs_bg_attr(int col);
+
static bool cursor_is_enabled = true;
static unsigned int convert_to_curses_attr( int chattr )
@@ -228,6 +231,50 @@ static void handle_hangup(int)
#endif // USE_UNIX_SIGNALS && SIGHUP_SAVE
+static WINDOW *Message_Window;
+static void setup_message_window()
+{
+ extern int get_message_window_height();
+
+ Message_Window = newwin( get_message_window_height(), get_number_of_cols(),
+ VIEW_EY, 0 );
+ if (!Message_Window)
+ {
+ fprintf(stderr, "Unable to create message window!");
+ exit(1);
+ }
+
+ scrollok(Message_Window, true);
+ idlok(Message_Window, true);
+}
+
+void clear_message_window()
+{
+ wattrset( Message_Window, curs_fg_attr(LIGHTGREY) );
+ werase( Message_Window );
+ wrefresh( Message_Window );
+}
+
+void message_out(int which_line, int color, const char *s, int firstcol,
+ bool newline)
+{
+ extern int get_message_window_height();
+
+ wattrset( Message_Window, curs_fg_attr(color) );
+
+ if (!firstcol)
+ firstcol = Options.delay_message_clear? 1 : 0;
+ else
+ firstcol--;
+
+ mvwaddstr(Message_Window, which_line, firstcol, s);
+
+ if (newline && which_line == get_message_window_height() - 1)
+ scroll(Message_Window);
+
+ wrefresh(Message_Window);
+}
+
void unixcurses_startup( void )
{
termio_init();
@@ -266,8 +313,9 @@ void unixcurses_startup( void )
setup_colour_pairs();
scrollok(stdscr, TRUE);
-}
+ setup_message_window();
+}
void unixcurses_shutdown()
{
@@ -406,12 +454,12 @@ void clear_to_end_of_screen(void)
clrtobot();
}
-int get_number_of_lines_from_curses(void)
+int get_number_of_lines(void)
{
return (LINES);
}
-int get_number_of_cols_from_curses(void)
+int get_number_of_cols(void)
{
return (COLS);
}
@@ -464,7 +512,7 @@ void textattr(int col)
textcolor(col);
}
-void textcolor(int col)
+static int curs_fg_attr(int col)
{
short fg, bg;
@@ -518,11 +566,15 @@ void textcolor(int col)
// figure out which colour pair we want
const int pair = (fg == 0 && bg == 0) ? 63 : (bg * 8 + fg);
- attrset( COLOR_PAIR(pair) | flags | Character_Set );
+ return ( COLOR_PAIR(pair) | flags | Character_Set );
}
+void textcolor(int col)
+{
+ attrset( curs_fg_attr(col) );
+}
-void textbackground(int col)
+static int curs_bg_attr(int col)
{
short fg, bg;
@@ -573,7 +625,12 @@ void textbackground(int col)
// figure out which colour pair we want
const int pair = (fg == 0 && bg == 0) ? 63 : (bg * 8 + fg);
- attrset( COLOR_PAIR(pair) | flags | Character_Set );
+ return ( COLOR_PAIR(pair) | flags | Character_Set );
+}
+
+void textbackground(int col)
+{
+ attrset( curs_bg_attr(col) );
}