curse.c (gdcalc-2.20) | : | curse.c (gdcalc-3.0) | ||
---|---|---|---|---|
skipping to change at line 21 | skipping to change at line 21 | |||
it under the terms of the GNU General Public License as published by | it under the terms of the GNU General Public License as published by | |||
the Free Software Foundation; either version 2 of the License, or | the Free Software Foundation; either version 2 of the License, or | |||
(at your option) any later version. | (at your option) any later version. | |||
This program is distributed in the hope that it will be useful, | This program is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | You should have received a copy of the GNU General Public License | |||
along with this program; see the file COPYING. If not, write to | along with this program; see the file COPYING. If not, write to | |||
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | the Free Software Foundation, Inc., 51 Franklin Street, Fifth | |||
Boston, MA 02111-1307, USA. | Floor, Boston, MA 02110-1301 USA | |||
*/ | */ | |||
#if NCURSES | #if NCURSES | |||
#include <ncurses/curses.h> | #include <ncurses/curses.h> | |||
#else | #else | |||
#include <curses.h> | #include <curses.h> | |||
#endif | #endif | |||
#include <ctype.h> | #include <ctype.h> | |||
#include <setjmp.h> | #include <setjmp.h> | |||
skipping to change at line 91 | skipping to change at line 91 | |||
#define START_X 2 | #define START_X 2 | |||
#define STARTL_Y 10 | #define STARTL_Y 10 | |||
#define STARTT_Y 11 | #define STARTT_Y 11 | |||
#define STARTZ_Y 12 | #define STARTZ_Y 12 | |||
#define STARTY_Y 13 | #define STARTY_Y 13 | |||
#define STARTX_Y 1 | #define STARTX_Y 1 | |||
#define BASE_X 0 | #define BASE_X 0 | |||
#define BASE_Y 0 | #define BASE_Y 0 | |||
#define FK_X 0 | #define FK_X 0 | |||
#define FK_Y 0 | #define FK_Y 0 | |||
#define INV_X 9 | #define INV_X 12 | |||
#define INV_Y 0 | #define INV_Y 0 | |||
#define TMODE_X 19 | #define TMODE_X 19 | |||
#define TMODE_Y 0 | #define TMODE_Y 0 | |||
#define INTLINEX 2 | #define INTLINEX 2 | |||
#define INTLINEY 11 | #define INTLINEY 11 | |||
#define ERRORX 0 | #define ERRORX 0 | |||
#define ERRORY 0 | #define ERRORY 0 | |||
#define WIDTH 36 | #define WIDTH 36 | |||
#define F1 0x340 | #define F1 0x340 | |||
skipping to change at line 155 | skipping to change at line 155 | |||
extern int entering, fk_set; | extern int entering, fk_set; | |||
/* FUNCTION KEY DEFINITIONS */ | /* FUNCTION KEY DEFINITIONS */ | |||
struct funckey { | struct funckey { | |||
char label[8]; | char label[8]; | |||
COMMAND function; | COMMAND function; | |||
}; | }; | |||
struct funckey func[NUMFK][8] = {{ | struct funckey func[NUMFK][8] = {{ | |||
{ "Float ", FIX, }, | { "Fix ", FIXFORMAT, }, | |||
{ "Engin. ", ENG, }, | { "Eng ", ENGFORMAT, }, | |||
{ "Sci ", SCIFORMAT }, | ||||
{ "Binary ", BIN, }, | { "Binary ", BIN, }, | |||
{ "Octal ", OCT, }, | { "Octal ", OCT, }, | |||
{ "Dec ", DEC, }, | { "Dec ", DEC, }, | |||
{ "Hex ", HEX, }, | { "Hex ", HEX, }, | |||
{ "Ascii ", ASCIIM, }, | { "Ascii ", ASCIIM, }, | |||
{ "HELP ", HELP, } | ||||
},{ | },{ | |||
{ "Sin ", SIN, }, | { "Sin ", SIN, }, | |||
{ "Cos ", COS, }, | { "Cos ", COS, }, | |||
{ "Tan ", TAN, }, | { "Tan ", TAN, }, | |||
{ "Log E ", LOGE, }, | { "Log E ", LOGE, }, | |||
{ "Log 10 ", LOG10, }, | { "Log 10 ", LOG10, }, | |||
{ " ", ASCIIZ, }, | { " ", ASCIIZ, }, | |||
{ " ", ASCIIZ, }, | ||||
{ "Inverse", INV, }, | { "Inverse", INV, }, | |||
{ "HELP ", HELP, }, | ||||
},{ | },{ | |||
{ "Square ", SQR, }, | { "Square ", SQR, }, | |||
{ "S Root ", ROOT, }, | { "S Root ", ROOT, }, | |||
{ "Cube ", CUBE, }, | { "Cube ", CUBE, }, | |||
{ "C root ", CROOT, }, | { "C root ", CROOT, }, | |||
{ "FRC ", FRC, }, | { "FRC ", FRC, }, | |||
{ "INT ", INT, }, | { "INT ", INT, }, | |||
{ " ", ASCIIZ, }, | { " ", ASCIIZ, }, | |||
{ "HELP ", HELP, }, | { " ", ASCIIZ, }, | |||
},{ | },{ | |||
{ "Sum ", SUM, }, | { "Sum ", SUM, }, | |||
{ "Mean ", MEAN, }, | { "Mean ", MEAN, }, | |||
{ "S Dev ", S_DEV, }, | { "S Dev ", S_DEV, }, | |||
{ "N ", NSTAT, }, | { "N ", NSTAT, }, | |||
{ "Clear ", SUM0, }, | { "Clear ", SUM0, }, | |||
{ "Sum- ", SUMR, }, | { "Sum- ", SUMR, }, | |||
{ " ", ASCIIZ, }, | { " ", ASCIIZ, }, | |||
{ "HELP ", HELP, }, | { " ", ASCIIZ, }, | |||
},{ | },{ | |||
{ "N ", NFIN, }, | { "N ", NFIN, }, | |||
{ "I ", INTST, }, | { "I ", INTST, }, | |||
{ "P Val ", PVAL, }, | { "P Val ", PVAL, }, | |||
{ "PMT ", PMT, }, | { "PMT ", PMT, }, | |||
{ "F Val ", FVAL, }, | { "F Val ", FVAL, }, | |||
{ " ", ASCIIZ, }, | { " ", ASCIIZ, }, | |||
{ " ", ASCIIZ, }, | ||||
{ "Inverse", INV, }, | { "Inverse", INV, }, | |||
{ "HELP ", HELP, }, | ||||
}}; | }}; | |||
void saveGuiSettings(FILE *f) {} | void saveGuiSettings(FILE *f) {} | |||
void readGuiSettings(char *b) {} | void readGuiSettings(char *b) {} | |||
int wnselect(x) | int wnselect(x) | |||
WINDOW *x; | WINDOW *x; | |||
{ | { | |||
curwin = x; | curwin = x; | |||
return(1); | return(1); | |||
skipping to change at line 401 | skipping to change at line 401 | |||
} | } | |||
/* d is always 0 for curses */ | /* d is always 0 for curses */ | |||
COMMAND map_key_to_func(c, d) | COMMAND map_key_to_func(c, d) | |||
COMMAND c, d; | COMMAND c, d; | |||
{ | { | |||
if (mode == PROG && intmode == BIN) | if (mode == PROG && intmode == BIN) | |||
if ((c&0xff80) == 0) /* Not a function key */ | if ((c&0xff80) == 0) /* Not a function key */ | |||
return(c); | return(c); | |||
if ((mode = PROG && intmode == HEX) && | if ((mode == PROG && intmode == HEX) && | |||
(((c >= 'a') && (c <= 'f')) || | (((c >= 'a') && (c <= 'f')) || | |||
((c >= 'A') && (c <= 'F')))) | ((c >= 'A') && (c <= 'F')))) | |||
return(c); | return(c); | |||
if ((c >= KEY_F(1)) && (c <= KEY_F(8))) | if ((c >= KEY_F(1)) && (c <= KEY_F(8))) | |||
return(func[fk_set][c - KEY_F(1)].function); | return(func[fk_set][c - KEY_F(1)].function); | |||
else switch (c) { | else switch (c) { | |||
case '\027': /* ^W = f1 */ | case '\027': /* ^W = f1 */ | |||
return(func[fk_set][0].function); | return(func[fk_set][0].function); | |||
case '\005': /* ^E = f2 */ | case '\005': /* ^E = f2 */ | |||
skipping to change at line 426 | skipping to change at line 426 | |||
return(func[fk_set][3].function); | return(func[fk_set][3].function); | |||
case '\031': /* ^Y = f5 */ | case '\031': /* ^Y = f5 */ | |||
return(func[fk_set][4].function); | return(func[fk_set][4].function); | |||
case '\025': /* ^U = f6 */ | case '\025': /* ^U = f6 */ | |||
return(func[fk_set][5].function); | return(func[fk_set][5].function); | |||
case '\011': /* ^I = f7 */ | case '\011': /* ^I = f7 */ | |||
return(func[fk_set][6].function); | return(func[fk_set][6].function); | |||
case '\017': /* ^O = f8 */ | case '\017': /* ^O = f8 */ | |||
return(func[fk_set][7].function); | return(func[fk_set][7].function); | |||
case 'D': | case 'V': | |||
case 'd': | case 'v': | |||
case KEY_DOWN: | case KEY_DOWN: | |||
return(ROLLDOWN); | return(ROLLDOWN); | |||
case KEY_F(10): | case KEY_F(10): | |||
case KEY_NPAGE: | case KEY_NPAGE: | |||
case '\016': /* ^N */ | case '\016': /* ^N */ | |||
return(NEXTKEYS); | return(NEXTKEYS); | |||
case KEY_F(9): | case KEY_F(9): | |||
case KEY_PPAGE: | case KEY_PPAGE: | |||
case '\020': /* ^P */ | case '\020': /* ^P */ | |||
return(PREVKEYS); | return(PREVKEYS); | |||
case KEY_DL: | case KEY_DL: | |||
case KEY_DC: | case KEY_DC: | |||
case KEY_EOL: | case KEY_EOL: | |||
case KEY_EOS: | case KEY_EOS: | |||
case KEY_CLEAR: | case KEY_CLEAR: | |||
case 'C': | case 'X': | |||
case 'c': | case 'x': | |||
return(CLX); | return(CLX); | |||
case '\004': /* ^D */ | case '\004': /* ^D */ | |||
case 'Q': | case 'Q': | |||
case 'q': | case 'q': | |||
case ESCAPE: | case ESCAPE: | |||
return(QUIT); | return(QUIT); | |||
case KEY_UP: | case KEY_UP: | |||
case '\n': | case '\n': | |||
skipping to change at line 532 | skipping to change at line 532 | |||
case 'R': | case 'R': | |||
return RECALL; | return RECALL; | |||
case 'S': | case 'S': | |||
return STORE; | return STORE; | |||
case 'T': | case 'T': | |||
return XNT; | return XNT; | |||
case 'Y': | case 'Y': | |||
return YTOX; | ||||
case 'X': | ||||
return XNY; | return XNY; | |||
case 'Z': | case 'Z': | |||
return XNZ; | return XNZ; | |||
case '@': | case '@': | |||
return REGISTER; | return REGISTER; | |||
case 'H': | case 'H': | |||
return HELP; | return HELP; | |||
skipping to change at line 600 | skipping to change at line 597 | |||
void | void | |||
pop_up_help() { | pop_up_help() { | |||
if (help_on) { | if (help_on) { | |||
werase(helpwin); | werase(helpwin); | |||
help_on = 0; | help_on = 0; | |||
} else { | } else { | |||
help_on = 1; | help_on = 1; | |||
wnselect(helpwin); | wnselect(helpwin); | |||
gotoxy(0, 0); | gotoxy(0, 0); | |||
print_attr("\2^\2D Exit DCALC \2X x<>y"); | print_attr("\2^\2D/q Exit DCALC \2Y x<>y"); | |||
gotoxy(0, row + 1); | gotoxy(0, row + 1); | |||
print_attr(" \2$ Places \2Y y^x"); | print_attr(" \2$ Places \2^ y^x"); | |||
gotoxy(0, row + 1); | gotoxy(0, row + 1); | |||
print_attr(" \2M Deg/Rad \2P Pi \2% x % of y"); | print_attr(" \2M Deg/Rad \2P Pi \2% x % of y"); | |||
gotoxy(0, row + 1); | gotoxy(0, row + 1); | |||
print_attr(" \2C CLX \2# y MODULO x"); | print_attr(" \2X CLX \2# y MODULO x"); | |||
gotoxy(0, row + 1); | gotoxy(0, row + 1); | |||
print_attr(" \2D ROLL DOWN \2& x AND y"); | print_attr(" \2V ROLL DOWN \2& x AND y"); | |||
gotoxy(0, row + 1); | gotoxy(0, row + 1); | |||
print_attr(" \2, CHS \2| x OR y "); | print_attr(" \2, CHS \2| x OR y "); | |||
gotoxy(0, row + 1); | gotoxy(0, row + 1); | |||
print_attr(" \2L Recall Last x \2^ x XOR y"); | print_attr(" \2L Recall Last x \2^ x XOR y"); | |||
gotoxy(0, row + 1); | gotoxy(0, row + 1); | |||
print_attr(" \2S Store \2~ complement x"); | print_attr(" \2S Store \2~ complement x"); | |||
gotoxy(0, row + 1); | gotoxy(0, row + 1); | |||
print_attr(" \2R Recall \2>,\2< y shifted x bits"); | print_attr(" \2R Recall \2>,\2< y shifted x bits"); | |||
gotoxy(0, row + 1); | gotoxy(0, row + 1); | |||
print_attr(" \2T x<>t \2Z x<>z"); | print_attr(" \2T x<>t \2Z x<>z"); | |||
skipping to change at line 793 | skipping to change at line 790 | |||
{ | { | |||
int i; | int i; | |||
for (i = 0; i < NUMREGS; i++) | for (i = 0; i < NUMREGS; i++) | |||
dispreg(i); | dispreg(i); | |||
} | } | |||
void prinbase() | void prinbase() | |||
{ | { | |||
char outbuf[45]; | char outbuf[45]; | |||
char *p = outbuf; | ||||
xwin_select(); | xwin_select(); | |||
gotoxy(BASE_X, BASE_Y); | gotoxy(BASE_X, BASE_Y); | |||
if (mode == PROG) | if (mode == PROG) { | |||
switch (intmode) { | switch (intmode) { | |||
case ASCIIM: | case ASCIIM: p += sprintf(p, "Asc "); break; | |||
print_string("Ascii "); | case BIN: p += sprintf(p, "Bin "); break; | |||
break; | case OCT: p += sprintf(p, "Oct "); break; | |||
case DEC: p += sprintf(p, "Dec "); break; | ||||
case BIN: | case HEX: p += sprintf(p, "Hex "); break; | |||
print_string("Binary "); | } | |||
break; | } else { | |||
switch (floatmode) { | ||||
case OCT: | case ENGFORMAT: p += sprintf(p, "Eng %d", decplaces); break; | |||
print_string("Octal "); | case SCIFORMAT: p += sprintf(p, "Sci %d", decplaces); break; | |||
break; | case FIXFORMAT: p += sprintf(p, "Fix %d", decplaces); break; | |||
case DEC: | ||||
print_string("Decimal "); | ||||
break; | ||||
case HEX: | ||||
print_string("Hex "); | ||||
break; | ||||
} else { | ||||
if (floatmode == ENG) | ||||
sprintf(outbuf, "Engin. %d", decplaces); | ||||
else | ||||
sprintf(outbuf, "Float %d", decplaces); | ||||
print_string(outbuf); | ||||
} | } | |||
} | ||||
print_string(outbuf); | ||||
} | } | |||
void print_inv() | void print_inv() | |||
{ | { | |||
xwin_select(); | xwin_select(); | |||
gotoxy(INV_X, INV_Y); | gotoxy(INV_X, INV_Y); | |||
if (invert) | if (invert) | |||
print_string("Inv "); | print_string("Inv "); | |||
else | else | |||
print_string(" "); | print_string(" "); | |||
End of changes. 22 change blocks. | ||||
50 lines changed or deleted | 35 lines changed or added |