From: ewt Date: Wed, 4 Dec 1996 19:17:26 +0000 (+0000) Subject: added newtSetFlags(), newtGetrc() X-Git-Tag: v0-9~34 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a1f110194cef5365c3c4f7e2536aab16db25e085;p=thirdparty%2Fnewt.git added newtSetFlags(), newtGetrc() --- diff --git a/newt.c b/newt.c index 9686a85..3b1107a 100644 --- a/newt.c +++ b/newt.c @@ -22,11 +22,13 @@ struct keymap { char * tc; }; -struct Window windowStack[20]; -struct Window * currentWindow = NULL; +static struct Window windowStack[20]; +static struct Window * currentWindow = NULL; -char * helplineStack[20]; -char ** currentHelpline = NULL; +static char * helplineStack[20]; +static char ** currentHelpline = NULL; + +static int cursorRow, cursorCol; static char * defaultHelpLine = " / between elements | selects | next screen" @@ -52,6 +54,7 @@ struct newtColors newtDefaultColorPalette = { "yellow", "blue", /* root text */ "blue", /* scale full */ "red", /* scale empty */ + "blue", "lightgray", /* disabled entry fg, bg */ }; static struct keymap keymap[] = { @@ -200,6 +203,8 @@ void newtSetColors(struct newtColors colors) { colors.emptyScale); SLtt_set_color(NEWT_COLORSET_FULLSCALE, "", "black", colors.fullScale); + SLtt_set_color(NEWT_COLORSET_DISENTRY, "", colors.disabledEntryFg, + colors.disabledEntryBg); } int newtGetKey(void) { @@ -365,11 +370,20 @@ void newtPopWindow(void) { newtRefresh(); } -void newtGotorc(int row, int col) { - if (!currentWindow) - SLsmg_gotorc(row, col); - else - SLsmg_gotorc(row + currentWindow->top, col + currentWindow->left); +void newtGetrc(int * row, int * col) { + *row = cursorRow; + *col = cursorCol; +} + +void newtGotorc(int newRow, int newCol) { + if (currentWindow) { + newRow += currentWindow->top; + newCol += currentWindow->left; + } + + cursorRow = newRow; + cursorCol = newCol; + SLsmg_gotorc(cursorRow, cursorCol); } void newtDrawBox(int left, int top, int width, int height, int shadow) { @@ -493,3 +507,16 @@ void newtDrawRootText(int row, int col, char * text) { SLsmg_gotorc(row, col); SLsmg_write_string(text); } + +int newtSetFlags(int oldFlags, int newFlags, enum newtFlagsSense sense) { + switch (sense) { + case NEWT_FLAGS_SET: + return oldFlags | newFlags; + + case NEWT_FLAGS_RESET: + return oldFlags & (~newFlags); + + default: + return oldFlags; + } +} diff --git a/newt_pr.h b/newt_pr.h index 5a8cf84..e6eb0a1 100644 --- a/newt_pr.h +++ b/newt_pr.h @@ -17,7 +17,10 @@ #define COLORSET_TEXTBOX NEWT_COLORSET_TEXTBOX #define COLORSET_ACTTEXTBOX NEWT_COLORSET_ACTTEXTBOX +int newtSetFlags(int oldFlags, int newFlags, enum newtFlagsSense sense); + void newtGotorc(int row, int col); +void newtGetrc(int * row, int * col); void newtDrawBox(int left, int top, int width, int height, int shadow); void newtClearBox(int left, int top, int width, int height);