From: ewt Date: Mon, 12 Aug 1996 20:04:56 +0000 (+0000) Subject: 1) added root text drawing X-Git-Tag: v0-9~51 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=81361f3e050d37ea6599bf6884e74079009a8e01;p=thirdparty%2Fnewt.git 1) added root text drawing 2) added help line stack 2) changed colorset define's to be NEWT_ --- diff --git a/newt.c b/newt.c index 6e659a8..460fe0b 100644 --- a/newt.c +++ b/newt.c @@ -25,6 +25,9 @@ struct keymap { struct Window windowStack[20]; struct Window * currentWindow = NULL; +char * helplineStack[20]; +char ** currentHelpline = NULL; + struct newtColors newtDefaultColorPalette = { "white", "blue", /* root fg, bg */ "black", "lightgray", /* border fg, bg */ @@ -41,6 +44,8 @@ struct newtColors newtDefaultColorPalette = { "yellow", "blue", /* active listbox fg, bg */ "black", "lightgray", /* textbox fg, bg */ "lightgray", "black", /* active textbox fg, bg */ + "white", "blue", /* help line */ + "yellow", "blue", /* root text */ }; static struct keymap keymap[] = { @@ -93,12 +98,14 @@ static char * version = "Newt windowing library version " VERSION "GNU Public Library. " "written by Erik Troan\n"; +static void newtDrawHelpline(void); + void newtRefresh(void) { SLsmg_refresh(); } void newtCls(void) { - SLsmg_set_color(COLORSET_ROOT); + SLsmg_set_color(NEWT_COLORSET_ROOT); SLsmg_gotorc(0, 0); SLsmg_erase_eos(); @@ -141,25 +148,32 @@ int newtFinished(void) { } void newtSetColors(struct newtColors colors) { - SLtt_set_color(COLORSET_ROOT, "", colors.rootFg, colors.rootBg); - SLtt_set_color(COLORSET_BORDER, "", colors.borderFg, colors.borderBg); - SLtt_set_color(COLORSET_WINDOW, "", colors.windowFg, colors.windowBg); - SLtt_set_color(COLORSET_SHADOW, "", colors.shadowFg, colors.shadowBg); - SLtt_set_color(COLORSET_TITLE, "", colors.titleFg, colors.titleBg); - SLtt_set_color(COLORSET_BUTTON, "", colors.buttonFg, colors.buttonBg); - SLtt_set_color(COLORSET_ACTBUTTON, "", colors.actButtonFg, + SLtt_set_color(NEWT_COLORSET_ROOT, "", colors.rootFg, colors.rootBg); + SLtt_set_color(NEWT_COLORSET_BORDER, "", colors.borderFg, colors.borderBg); + SLtt_set_color(NEWT_COLORSET_WINDOW, "", colors.windowFg, colors.windowBg); + SLtt_set_color(NEWT_COLORSET_SHADOW, "", colors.shadowFg, colors.shadowBg); + SLtt_set_color(NEWT_COLORSET_TITLE, "", colors.titleFg, colors.titleBg); + SLtt_set_color(NEWT_COLORSET_BUTTON, "", colors.buttonFg, colors.buttonBg); + SLtt_set_color(NEWT_COLORSET_ACTBUTTON, "", colors.actButtonFg, colors.actButtonBg); - SLtt_set_color(COLORSET_CHECKBOX, "", colors.checkboxFg, colors.checkboxBg); - SLtt_set_color(COLORSET_ACTCHECKBOX, "", colors.actCheckboxFg, + SLtt_set_color(NEWT_COLORSET_CHECKBOX, "", colors.checkboxFg, + colors.checkboxBg); + SLtt_set_color(NEWT_COLORSET_ACTCHECKBOX, "", colors.actCheckboxFg, colors.actCheckboxBg); - SLtt_set_color(COLORSET_ENTRY, "", colors.entryFg, colors.entryBg); - SLtt_set_color(COLORSET_LABEL, "", colors.labelFg, colors.labelBg); - SLtt_set_color(COLORSET_LISTBOX, "", colors.listboxFg, colors.listboxBg); - SLtt_set_color(COLORSET_ACTLISTBOX, "", colors.actListboxFg, - colors.actListboxBg); - SLtt_set_color(COLORSET_TEXTBOX, "", colors.textboxFg, colors.textboxBg); - SLtt_set_color(COLORSET_ACTTEXTBOX, "", colors.actTextboxFg, - colors.actTextboxBg); + SLtt_set_color(NEWT_COLORSET_ENTRY, "", colors.entryFg, colors.entryBg); + SLtt_set_color(NEWT_COLORSET_LABEL, "", colors.labelFg, colors.labelBg); + SLtt_set_color(NEWT_COLORSET_LISTBOX, "", colors.listboxFg, + colors.listboxBg); + SLtt_set_color(NEWT_COLORSET_ACTLISTBOX, "", colors.actListboxFg, + colors.actListboxBg); + SLtt_set_color(NEWT_COLORSET_TEXTBOX, "", colors.textboxFg, + colors.textboxBg); + SLtt_set_color(NEWT_COLORSET_ACTTEXTBOX, "", colors.actTextboxFg, + colors.actTextboxBg); + SLtt_set_color(NEWT_COLORSET_HELPLINE, "", colors.helpLineFg, + colors.helpLineBg); + SLtt_set_color(NEWT_COLORSET_ROOTTEXT, "", colors.rootTextFg, + colors.rootTextBg); } int newtGetKey(void) { @@ -263,7 +277,7 @@ int newtOpenWindow(int left, int top, int width, int height, } } - SLsmg_set_color(COLORSET_BORDER); + SLsmg_set_color(NEWT_COLORSET_BORDER); SLsmg_draw_box(top - 1, left - 1, height + 2, width + 2); if (title) { @@ -274,19 +288,19 @@ int newtOpenWindow(int left, int top, int width, int height, SLsmg_write_char(SLSMG_RTEE_CHAR); SLsmg_set_char_set(0); SLsmg_write_char(' '); - SLsmg_set_color(COLORSET_TITLE); + SLsmg_set_color(NEWT_COLORSET_TITLE); SLsmg_write_string(title); - SLsmg_set_color(COLORSET_BORDER); + SLsmg_set_color(NEWT_COLORSET_BORDER); SLsmg_write_char(' '); SLsmg_set_char_set(1); SLsmg_write_char(SLSMG_LTEE_CHAR); SLsmg_set_char_set(0); } - SLsmg_set_color(COLORSET_WINDOW); + SLsmg_set_color(NEWT_COLORSET_WINDOW); SLsmg_fill_region(top, left, height, width, ' '); - SLsmg_set_color(COLORSET_SHADOW); + SLsmg_set_color(NEWT_COLORSET_SHADOW); SLsmg_fill_region(top + height + 1, left, 1, width + 2, ' '); SLsmg_fill_region(top, left + width + 1, height + 1, 1, ' '); @@ -341,7 +355,7 @@ void newtDrawBox(int left, int top, int width, int height, int shadow) { SLsmg_draw_box(top, left, height, width); if (shadow) { - SLsmg_set_color(COLORSET_SHADOW); + SLsmg_set_color(NEWT_COLORSET_SHADOW); SLsmg_fill_region(top + height, left + 1, 1, width - 1, ' '); SLsmg_fill_region(top + 1, left + width, height, 1, ' '); } @@ -396,3 +410,49 @@ struct eventResult newtDefaultEventHandler(struct newtComponent * c, er.result = ER_IGNORED; return er; } + +static void newtDrawHelpline(void) { + char * buf; + + SLsmg_set_color(NEWT_COLORSET_HELPLINE); + + buf = alloca(SLtt_Screen_Cols + 1); + memset(buf, ' ', SLtt_Screen_Cols); + buf[SLtt_Screen_Cols] = '\0'; + + if (currentHelpline) + memcpy(buf, *currentHelpline, strlen(*currentHelpline)); + + SLsmg_gotorc(SLtt_Screen_Rows - 1, 0); + SLsmg_write_string(buf); +} + +void newtPushHelpLine(char * text) { + if (currentHelpline) + (*(++currentHelpline)) = strdup(text); + else { + currentHelpline = helplineStack; + *currentHelpline = strdup(text); + } + + newtDrawHelpline(); +} + +void newtPopHelpLine(void) { + if (!currentHelpline) return; + + free(*currentHelpline); + if (currentHelpline == helplineStack) + currentHelpline = NULL; + else + currentHelpline--; + + newtDrawHelpline(); +} + +void newtDrawRootText(int row, int col, char * text) { + SLsmg_set_color(NEWT_COLORSET_ROOTTEXT); + + SLsmg_gotorc(row, col); + SLsmg_write_string(text); +}