| 1 |
/***************************************************************************** |
| 2 |
* Free42 -- an HP-42S calculator simulator |
| 3 |
* Copyright (C) 2004-2026 Thomas Okken |
| 4 |
* |
| 5 |
* This program is free software; you can redistribute it and/or modify |
| 6 |
* it under the terms of the GNU General Public License, version 2, |
| 7 |
* as published by the Free Software Foundation. |
| 8 |
* |
| 9 |
* This program is distributed in the hope that it will be useful, |
| 10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
* GNU General Public License for more details. |
| 13 |
* |
| 14 |
* You should have received a copy of the GNU General Public License |
| 15 |
* along with this program; if not, see http://www.gnu.org/licenses/. |
| 16 |
*****************************************************************************/ |
| 17 |
|
| 18 |
#include <stdlib.h> |
| 19 |
#include <string.h> |
| 20 |
|
| 21 |
#include "core_keydown.h" |
| 22 |
#include "core_commands2.h" |
| 23 |
#include "core_commands3.h" |
| 24 |
#include "core_commands4.h" |
| 25 |
#include "core_display.h" |
| 26 |
#include "core_helpers.h" |
| 27 |
#include "core_main.h" |
| 28 |
#include "core_math1.h" |
| 29 |
#include "core_tables.h" |
| 30 |
#include "core_variables.h" |
| 31 |
#include "shell.h" |
| 32 |
|
| 33 |
|
| 34 |
static bool is_number_key(int shift, int key, bool *invalid) { |
| 35 |
*invalid = false; |
| 36 |
if (get_front_menu() == MENU_BASE_A_THRU_F |
| 37 |
&& (key == KEY_SIGMA || key == KEY_INV || key == KEY_SQRT |
| 38 |
|| key == KEY_LOG || key == KEY_LN || key == KEY_XEQ)) |
| 39 |
return true; |
| 40 |
if (shift) |
| 41 |
return false; |
| 42 |
if (key == KEY_0 || key == KEY_1) |
| 43 |
return true; |
| 44 |
int base = get_base(); |
| 45 |
if (key == KEY_DOT || key == KEY_E) { |
| 46 |
*invalid = base != 10; |
| 47 |
return true; |
| 48 |
} |
| 49 |
if (key == KEY_2 || key == KEY_3 || key == KEY_4 |
| 50 |
|| key == KEY_5 || key == KEY_6 || key == KEY_7) { |
| 51 |
*invalid = base == 2; |
| 52 |
return true; |
| 53 |
} |
| 54 |
if (key == KEY_8 || key == KEY_9) { |
| 55 |
*invalid = base == 2 || base == 8; |
| 56 |
return true; |
| 57 |
} |
| 58 |
return false; |
| 59 |
} |
| 60 |
|
| 61 |
static bool basekeys() { |
| 62 |
if (!baseapp) |
| 63 |
return false; |
| 64 |
int menu = get_front_menu(); |
| 65 |
return menu >= MENU_BASE1 && menu <= MENU_BASE_DISP; |
| 66 |
} |
| 67 |
|
| 68 |
static void set_solve_integ(int solve) { |
| 69 |
if (solve) |
| 70 |
print_menu_trace("SOLVER", 6); |
| 71 |
else |
| 72 |
print_menu_trace("\3f(x)", 5); |
| 73 |
if (flags.f.prgm_mode || !mvar_prgms_exist()) { |
| 74 |
set_menu(MENULEVEL_APP, solve ? MENU_SOLVE : MENU_INTEG); |
| 75 |
if (!flags.f.prgm_mode) |
| 76 |
display_error(ERR_NO_MENU_VARIABLES); |
| 77 |
} else { |
| 78 |
int err = set_menu_return_err(MENULEVEL_APP, MENU_CATALOG, false); |
| 79 |
if (err == ERR_NONE) { |
| 80 |
set_cat_section(solve ? CATSECT_PGM_SOLVE : CATSECT_PGM_INTEG); |
| 81 |
move_cat_row(0); |
| 82 |
clear_row(0); |
| 83 |
if (solve) |
| 84 |
draw_string(0, 0, "Select Solve Program", 20); |
| 85 |
else |
| 86 |
draw_string(0, 0, "Select \3f(x) Program", 20); |
| 87 |
flags.f.message = 1; |
| 88 |
flags.f.two_line_message = 0; |
| 89 |
} else |
| 90 |
display_error(err); |
| 91 |
} |
| 92 |
redisplay(); |
| 93 |
} |
| 94 |
|
| 95 |
static void view(const char *varname, int varlength) { |
| 96 |
arg_struct arg; |
| 97 |
int i, err; |
| 98 |
arg.type = ARGTYPE_STR; |
| 99 |
arg.length = varlength; |
| 100 |
for (i = 0; i < varlength; i++) |
| 101 |
arg.val.text[i] = varname[i]; |
| 102 |
err = view_helper(&arg, 0); |
| 103 |
if (err != ERR_NONE) { |
| 104 |
display_error(err); |
| 105 |
flush_display(); |
| 106 |
pending_command = CMD_NONE; |
| 107 |
} else { |
| 108 |
flags.f.message = 0; |
| 109 |
pending_command = CMD_LINGER1; |
| 110 |
shell_request_timeout3(2000); |
| 111 |
} |
| 112 |
} |
| 113 |
|
| 114 |
struct cmd_getkey_mapping_struct { |
| 115 |
int2 key; |
| 116 |
int2 cmd; |
| 117 |
}; |
| 118 |
|
| 119 |
static cmd_getkey_mapping_struct cmd_getkey_mapping[] = { |
| 120 |
{ 1, CMD_SIGMAADD }, |
| 121 |
{ 2, CMD_INV }, |
| 122 |
{ 3, CMD_SQRT }, |
| 123 |
{ 4, CMD_LOG }, |
| 124 |
{ 5, CMD_LN }, |
| 125 |
{ 6, CMD_XEQ }, |
| 126 |
{ 7, CMD_STO }, |
| 127 |
{ 8, CMD_RCL }, |
| 128 |
{ 9, CMD_RDN }, |
| 129 |
{ 10, CMD_SIN }, |
| 130 |
{ 11, CMD_COS }, |
| 131 |
{ 12, CMD_TAN }, |
| 132 |
{ 13, CMD_ENTER }, |
| 133 |
{ 14, CMD_SWAP }, |
| 134 |
{ 15, CMD_CHS }, |
| 135 |
{ 22, CMD_DIV }, |
| 136 |
{ 27, CMD_MUL }, |
| 137 |
{ 32, CMD_SUB }, |
| 138 |
{ 37, CMD_ADD }, |
| 139 |
{ 38, CMD_SIGMASUB }, |
| 140 |
{ 39, CMD_Y_POW_X }, |
| 141 |
{ 40, CMD_SQUARE }, |
| 142 |
{ 41, CMD_10_POW_X }, |
| 143 |
{ 42, CMD_E_POW_X }, |
| 144 |
{ 43, CMD_GTO }, |
| 145 |
{ 44, CMD_COMPLEX }, |
| 146 |
{ 45, CMD_PERCENT }, |
| 147 |
{ 46, CMD_PI }, |
| 148 |
{ 47, CMD_ASIN }, |
| 149 |
{ 48, CMD_ACOS }, |
| 150 |
{ 49, CMD_ATAN }, |
| 151 |
{ 51, CMD_LASTX }, |
| 152 |
{ 55, CMD_BST }, |
| 153 |
{ 60, CMD_SST }, |
| 154 |
{ 66, CMD_ASSIGNa }, |
| 155 |
{ 70, CMD_OFF }, |
| 156 |
{ 0, CMD_NONE } |
| 157 |
}; |
| 158 |
|
| 159 |
int find_cmd_getkey_mapping(int cmd) { |
| 160 |
cmd_getkey_mapping_struct *gm = cmd_getkey_mapping; |
| 161 |
while (true) { |
| 162 |
if (gm->key == 0) |
| 163 |
// Command that's not on the standard keyboard |
| 164 |
return 0; |
| 165 |
else if (gm->cmd == cmd) |
| 166 |
return gm->key; |
| 167 |
gm++; |
| 168 |
} |
| 169 |
} |
| 170 |
|
| 171 |
void keydown(int shift, int key) { |
| 172 |
// Preserve state of Shift, to allow MENU handlers to implement |
| 173 |
// different behaviors for unshifted and shifted menu keys. |
| 174 |
flags.f.shift_state = shift; |
| 175 |
|
| 176 |
pending_command = CMD_NONE; |
| 177 |
|
| 178 |
if (key >= 1024 && key < 2048) { |
| 179 |
/* TODO: is this actually needed? |
| 180 |
* Filtering out ASCII key events if the alpha menu is not actually |
| 181 |
* active, just in case the subsequent key handling code doesn't |
| 182 |
* handle them properly in all cases. Using a code coverage tool on |
| 183 |
* the keydown handler might be an idea... |
| 184 |
*/ |
| 185 |
int menu = get_front_menu(); |
| 186 |
if (menu < MENU_ALPHA1 || menu > MENU_ALPHA_MISC2) |
| 187 |
return; |
| 188 |
} else if (key < 1 || key > 37 && key < 2048) { |
| 189 |
/* Bad key code */ |
| 190 |
squeak(); |
| 191 |
return; |
| 192 |
} |
| 193 |
|
| 194 |
if (mode_clall) { |
| 195 |
if (!shift && key == KEY_SIGMA) |
| 196 |
pending_command = CMD_CLALLb; |
| 197 |
else if (key == KEY_EXIT) |
| 198 |
pending_command = CMD_CANCELLED; |
| 199 |
else |
| 200 |
pending_command = CMD_NULL; |
| 201 |
mode_clall = false; |
| 202 |
return; |
| 203 |
} |
| 204 |
|
| 205 |
if (mode_getkey) { |
| 206 |
if (key >= 2048) { |
| 207 |
// Direct command mapping |
| 208 |
int cmd = key - 2048; |
| 209 |
key = find_cmd_getkey_mapping(cmd); |
| 210 |
if (key == 0) { |
| 211 |
squeak(); |
| 212 |
set_annunciators(-1, -1, -1, 0, -1, -1); |
| 213 |
return; |
| 214 |
} |
| 215 |
} else { |
| 216 |
if (shift) |
| 217 |
key += 37; |
| 218 |
} |
| 219 |
vartype *result = new_real(key); |
| 220 |
if (result != NULL) { |
| 221 |
if (recall_result(result) != ERR_NONE) |
| 222 |
goto nomem; |
| 223 |
flags.f.stack_lift_disable = 0; |
| 224 |
} else { |
| 225 |
nomem: |
| 226 |
display_error(ERR_INSUFFICIENT_MEMORY); |
| 227 |
set_running(false); |
| 228 |
} |
| 229 |
if (key == KEY_RUN || !mode_getkey1 && (key == KEY_EXIT || key == KEY_EXIT + 37)) |
| 230 |
set_running(false); |
| 231 |
mode_getkey = false; |
| 232 |
if (!mode_running) |
| 233 |
redisplay(); |
| 234 |
return; |
| 235 |
} |
| 236 |
|
| 237 |
if (shift && key == KEY_EXIT) { |
| 238 |
pending_command = CMD_SILENT_OFF; |
| 239 |
return; |
| 240 |
} |
| 241 |
|
| 242 |
if (shift && key == KEY_RUN) { |
| 243 |
if (mode_command_entry) { |
| 244 |
squeak(); |
| 245 |
return; |
| 246 |
} |
| 247 |
if (flags.f.prgm_mode) { |
| 248 |
if (mode_alpha_entry) |
| 249 |
finish_alpha_prgm_line(); |
| 250 |
else if (mode_number_entry) { |
| 251 |
arg_struct arg; |
| 252 |
arg.type = ARGTYPE_DOUBLE; |
| 253 |
arg.val_d = entered_number; |
| 254 |
cmdline[cmdline_length] = 0; |
| 255 |
store_command(pc, CMD_NUMBER, &arg, cmdline); |
| 256 |
prgm_highlight_row = 1; |
| 257 |
} |
| 258 |
} else if (mode_alpha_entry) { |
| 259 |
if ((flags.f.trace_print || flags.f.normal_print) |
| 260 |
&& flags.f.printer_exists) |
| 261 |
docmd_pra(NULL); |
| 262 |
} else if (mode_number_entry) { |
| 263 |
if ((flags.f.trace_print || flags.f.normal_print) |
| 264 |
&& flags.f.printer_exists) { |
| 265 |
deferred_print = 1; |
| 266 |
print_command(CMD_NULL, NULL); |
| 267 |
} |
| 268 |
} |
| 269 |
|
| 270 |
print_menu_trace_always("PRGM", 4); |
| 271 |
|
| 272 |
mode_alpha_entry = false; |
| 273 |
mode_number_entry = false; |
| 274 |
flags.f.prgm_mode = !flags.f.prgm_mode; |
| 275 |
|
| 276 |
mode_varmenu = false; |
| 277 |
if (flags.f.prgm_mode) { |
| 278 |
if (mode_appmenu == MENU_BASE_A_THRU_F) |
| 279 |
set_menu(MENULEVEL_APP, MENU_BASE1); |
| 280 |
else if (mode_plainmenu == MENU_PROGRAMMABLE) |
| 281 |
set_menu(MENULEVEL_PLAIN, MENU_NONE); |
| 282 |
input_length = 0; |
| 283 |
} |
| 284 |
flags.f.message = 0; |
| 285 |
flags.f.two_line_message = 0; |
| 286 |
redisplay(); |
| 287 |
return; |
| 288 |
} |
| 289 |
|
| 290 |
if (flags.f.message && !shift && key == KEY_BSP) { |
| 291 |
flags.f.message = 0; |
| 292 |
flags.f.two_line_message = 0; |
| 293 |
redisplay(); |
| 294 |
return; |
| 295 |
} |
| 296 |
|
| 297 |
flags.f.message = 0; |
| 298 |
flags.f.two_line_message = 0; |
| 299 |
|
| 300 |
if (mode_number_entry && get_base() == 16 && key == KEY_SIGMA |
| 301 |
&& get_front_menu() == MENU_BASE1) { |
| 302 |
/* Special case -- entering the A...F menu while in base 16 |
| 303 |
* does *not* cancel number entry mode (unlike all other menu |
| 304 |
* keys)... So we intercept and handle it before all the other |
| 305 |
* logic can mess things up. |
| 306 |
*/ |
| 307 |
keydown_number_entry(-1, -1); |
| 308 |
return; |
| 309 |
} |
| 310 |
|
| 311 |
bool invalid; |
| 312 |
if (mode_number_entry |
| 313 |
&& !is_number_key(shift, key, &invalid) |
| 314 |
&& (key != KEY_CHS || shift || basekeys() || get_base() != 10) |
| 315 |
&& (key != KEY_BSP || shift)) { |
| 316 |
if (invalid) |
| 317 |
return; |
| 318 |
/* Leaving number entry mode */ |
| 319 |
mode_number_entry = false; |
| 320 |
if (flags.f.prgm_mode) { |
| 321 |
arg_struct arg; |
| 322 |
arg.type = ARGTYPE_DOUBLE; |
| 323 |
arg.val_d = entered_number; |
| 324 |
cmdline[cmdline_length] = 0; |
| 325 |
store_command(pc, CMD_NUMBER, &arg, cmdline); |
| 326 |
prgm_highlight_row = 1; |
| 327 |
} else if ((flags.f.trace_print || flags.f.normal_print) |
| 328 |
&& flags.f.printer_exists) |
| 329 |
deferred_print = 1; |
| 330 |
if (flags.f.big_stack && !shift && key == KEY_ENTER) { |
| 331 |
redisplay(); |
| 332 |
return; |
| 333 |
} |
| 334 |
} |
| 335 |
|
| 336 |
if (mode_command_entry |
| 337 |
&& (shift || get_front_menu() == MENU_NONE) |
| 338 |
&& (key == KEY_UP || key == KEY_DOWN)) { |
| 339 |
/* Trying to do SST or BST while in command entry mode */ |
| 340 |
squeak(); |
| 341 |
return; |
| 342 |
} |
| 343 |
|
| 344 |
if (key == KEY_UP || (key == KEY_DOWN && |
| 345 |
(flags.f.prgm_mode || (!shift && get_front_menu() != MENU_NONE)))) { |
| 346 |
/* UP, DOWN, BST, or prgm-mode SST */ |
| 347 |
repeating = 1; |
| 348 |
repeating_shift = shift; |
| 349 |
repeating_key = key; |
| 350 |
} |
| 351 |
|
| 352 |
if (flags.f.prgm_mode && (key == KEY_UP || key == KEY_DOWN) |
| 353 |
&& (shift || get_front_menu() == MENU_NONE)) { |
| 354 |
/* Stepping through the program in prgm mode */ |
| 355 |
if (flags.f.prgm_mode && mode_alpha_entry) |
| 356 |
finish_alpha_prgm_line(); |
| 357 |
clear_all_rtns(); |
| 358 |
if (key == KEY_UP) |
| 359 |
bst(); |
| 360 |
else |
| 361 |
sst(); |
| 362 |
redisplay(); |
| 363 |
return; |
| 364 |
} |
| 365 |
|
| 366 |
if (key == KEY_UP || key == KEY_DOWN) { |
| 367 |
if (get_front_menu() == MENU_CATALOG) { |
| 368 |
int sect = get_cat_section(); |
| 369 |
switch (sect) { |
| 370 |
case CATSECT_TOP: |
| 371 |
sect = key == KEY_UP ? CATSECT_EXT_2 : CATSECT_EXT_1; |
| 372 |
break; |
| 373 |
case CATSECT_EXT_1: |
| 374 |
sect = key == KEY_UP ? CATSECT_TOP : CATSECT_EXT_2; |
| 375 |
break; |
| 376 |
case CATSECT_EXT_2: |
| 377 |
sect = key == KEY_UP ? CATSECT_EXT_1 : CATSECT_TOP; |
| 378 |
break; |
| 379 |
default: |
| 380 |
sect = -1; |
| 381 |
break; |
| 382 |
} |
| 383 |
if (sect != -1) { |
| 384 |
set_cat_section(sect); |
| 385 |
redisplay(); |
| 386 |
return; |
| 387 |
} |
| 388 |
} |
| 389 |
} |
| 390 |
|
| 391 |
if (!flags.f.prgm_mode && key == KEY_UP |
| 392 |
&& (shift || get_front_menu() == MENU_NONE)) { |
| 393 |
/* BST in normal or alpha mode */ |
| 394 |
if (mode_alpha_entry |
| 395 |
&& (flags.f.trace_print || flags.f.normal_print) |
| 396 |
&& flags.f.printer_exists) |
| 397 |
docmd_pra(NULL); |
| 398 |
mode_alpha_entry = false; |
| 399 |
clear_all_rtns(); |
| 400 |
bst(); |
| 401 |
flags.f.prgm_mode = 1; |
| 402 |
redisplay(); |
| 403 |
flags.f.prgm_mode = 0; |
| 404 |
pending_command = CMD_CANCELLED; |
| 405 |
return; |
| 406 |
} |
| 407 |
|
| 408 |
if (mode_number_entry) |
| 409 |
keydown_number_entry(shift, key); |
| 410 |
else if (mode_command_entry) |
| 411 |
keydown_command_entry(shift, key); |
| 412 |
else if (alpha_active()) |
| 413 |
keydown_alpha_mode(shift, key); |
| 414 |
else |
| 415 |
keydown_normal_mode(shift, key); |
| 416 |
} |
| 417 |
|
| 418 |
void keydown_number_entry(int shift, int key) { |
| 419 |
phloat x; |
| 420 |
char buf[100]; |
| 421 |
int bufptr; |
| 422 |
int base = get_base(); |
| 423 |
|
| 424 |
if (key == -1) { |
| 425 |
/* Hack... The user is switching to the A...F menu */ |
| 426 |
set_menu(MENULEVEL_APP, MENU_BASE_A_THRU_F); |
| 427 |
redisplay(); |
| 428 |
goto draw_number; |
| 429 |
} |
| 430 |
|
| 431 |
if (base != 10 && (key == KEY_E || key == KEY_DOT)) |
| 432 |
return; |
| 433 |
|
| 434 |
/* NOTE: 'key' can only be KEY_CHS at this point in the code |
| 435 |
* if 'baseapp' is false and get_base() returns 10; in all other |
| 436 |
* cases, the +/- key will end number entry mode and we won't |
| 437 |
* get here, and the CMD_CHS or CMD_BASECHS function will be |
| 438 |
* invoked instead. |
| 439 |
*/ |
| 440 |
|
| 441 |
if (key == KEY_BSP && cmdline_length == 1) { |
| 442 |
char pne = mode_number_entry; |
| 443 |
mode_number_entry = false; |
| 444 |
if (flags.f.prgm_mode) { |
| 445 |
pc = line2pc(pc2line(pc) - 1); |
| 446 |
prgm_highlight_row = 0; |
| 447 |
redisplay(); |
| 448 |
return; |
| 449 |
} else { |
| 450 |
pending_command = flags.f.big_stack ? pne == 2 ? CMD_DROP_CANCL : CMD_DROP : CMD_CLX; |
| 451 |
return; |
| 452 |
} |
| 453 |
} |
| 454 |
|
| 455 |
if (key == KEY_BSP) { |
| 456 |
cmdline_length--; |
| 457 |
if (!flags.f.prgm_mode) |
| 458 |
if (base == 10) |
| 459 |
fix_thousands_separators(cmdline, &cmdline_length); |
| 460 |
else |
| 461 |
fix_base_separators(cmdline, &cmdline_length); |
| 462 |
if (core_settings.auto_repeat) { |
| 463 |
repeating = 2; |
| 464 |
repeating_key = key; |
| 465 |
repeating_shift = shift; |
| 466 |
} |
| 467 |
} else if (key == KEY_CHS) { |
| 468 |
/* Check if mantissa or exponent gets the sign change */ |
| 469 |
int i; |
| 470 |
int exp_pos = -1; |
| 471 |
for (i = 0; i < cmdline_length; i++) |
| 472 |
if (cmdline[i] == 24) { |
| 473 |
exp_pos = i; |
| 474 |
break; |
| 475 |
} |
| 476 |
if (exp_pos != -1) { |
| 477 |
/* Change exponent sign */ |
| 478 |
int failed = 0; |
| 479 |
phloat d; |
| 480 |
undo_chs_exp: |
| 481 |
if (cmdline_length > exp_pos + 1 |
| 482 |
&& cmdline[exp_pos + 1] == '-') { |
| 483 |
for (i = exp_pos + 1; i < cmdline_length - 1; i++) |
| 484 |
cmdline[i] = cmdline[i + 1]; |
| 485 |
cmdline_length--; |
| 486 |
} else { |
| 487 |
for (i = cmdline_length; i > exp_pos + 1; i--) |
| 488 |
cmdline[i] = cmdline[i - 1]; |
| 489 |
cmdline[exp_pos + 1] = '-'; |
| 490 |
cmdline_length++; |
| 491 |
} |
| 492 |
if (!failed) { |
| 493 |
if (string2phloat(cmdline, cmdline_length, &d) != 0) { |
| 494 |
failed = 1; |
| 495 |
goto undo_chs_exp; |
| 496 |
} |
| 497 |
} else |
| 498 |
return; |
| 499 |
} else { |
| 500 |
/* Change mantissa sign */ |
| 501 |
if (cmdline[0] == '-') { |
| 502 |
if (cmdline_length == 1) { |
| 503 |
if (flags.f.prgm_mode) { |
| 504 |
mode_number_entry = false; |
| 505 |
pc = line2pc(pc2line(pc) - 1); |
| 506 |
prgm_highlight_row = 0; |
| 507 |
redisplay(); |
| 508 |
return; |
| 509 |
} else { |
| 510 |
/* This is a bit odd, but it's how the HP-42S |
| 511 |
* does it, so there. |
| 512 |
*/ |
| 513 |
free_vartype(stack[sp]); |
| 514 |
stack[sp] = new_real(0); |
| 515 |
pending_command = flags.f.big_stack ? mode_number_entry == 2 ? CMD_DROP_CANCL : CMD_DROP : CMD_CLX; |
| 516 |
mode_number_entry = false; |
| 517 |
return; |
| 518 |
} |
| 519 |
} |
| 520 |
for (i = 0; i < cmdline_length - 1; i++) |
| 521 |
cmdline[i] = cmdline[i + 1]; |
| 522 |
cmdline_length--; |
| 523 |
} else { |
| 524 |
for (i = cmdline_length; i > 0; i--) |
| 525 |
cmdline[i] = cmdline[i - 1]; |
| 526 |
cmdline[0] = '-'; |
| 527 |
cmdline_length++; |
| 528 |
} |
| 529 |
} |
| 530 |
} else if (key == KEY_E) { |
| 531 |
int exp_pos = -1; |
| 532 |
int only_zeroes = 1; |
| 533 |
int seen_dot = 0; |
| 534 |
char dot = flags.f.decimal_point ? '.' : ','; |
| 535 |
int i; |
| 536 |
for (i = 0; i < cmdline_length; i++) { |
| 537 |
char c = cmdline[i]; |
| 538 |
if (c >= '1' && c <= '9') |
| 539 |
only_zeroes = 0; |
| 540 |
else if (c == dot) |
| 541 |
seen_dot = 1; |
| 542 |
else if (c == 24) { |
| 543 |
exp_pos = i; |
| 544 |
break; |
| 545 |
} |
| 546 |
} |
| 547 |
if (exp_pos == -1) { |
| 548 |
if (only_zeroes) { |
| 549 |
if (cmdline_length > 0 && cmdline[0] == '-') |
| 550 |
cmdline_length = 1; |
| 551 |
else |
| 552 |
cmdline_length = 0; |
| 553 |
cmdline[cmdline_length++] = '1'; |
| 554 |
if (seen_dot) |
| 555 |
cmdline[cmdline_length++] = dot; |
| 556 |
} |
| 557 |
cmdline[cmdline_length++] = 24; |
| 558 |
} else |
| 559 |
return; |
| 560 |
} else if (key == KEY_DOT) { |
| 561 |
if (cmdline_length == 0 || |
| 562 |
(cmdline_length == 1 && cmdline[0] == '-')) { |
| 563 |
cmdline[cmdline_length++] = '0'; |
| 564 |
cmdline[cmdline_length++] = flags.f.decimal_point ? '.' : ','; |
| 565 |
} else { |
| 566 |
/* Only allow dot if there isn't one already, and |
| 567 |
* there is no exponent either |
| 568 |
*/ |
| 569 |
int dot_or_exp_pos = -1; |
| 570 |
int i; |
| 571 |
char dot = flags.f.decimal_point ? '.' : ','; |
| 572 |
for (i = 0; i < cmdline_length; i++) |
| 573 |
if (cmdline[i] == dot || cmdline[i] == 24) { |
| 574 |
dot_or_exp_pos = i; |
| 575 |
break; |
| 576 |
} |
| 577 |
if (dot_or_exp_pos == -1) |
| 578 |
cmdline[cmdline_length++] = dot; |
| 579 |
else |
| 580 |
return; |
| 581 |
} |
| 582 |
} else /* KEY_0 .. KEY_9 or hex A-F */ { |
| 583 |
int digit; |
| 584 |
char c; |
| 585 |
switch (key) { |
| 586 |
case KEY_0: digit = 0; break; |
| 587 |
case KEY_1: digit = 1; break; |
| 588 |
case KEY_2: digit = 2; break; |
| 589 |
case KEY_3: digit = 3; break; |
| 590 |
case KEY_4: digit = 4; break; |
| 591 |
case KEY_5: digit = 5; break; |
| 592 |
case KEY_6: digit = 6; break; |
| 593 |
case KEY_7: digit = 7; break; |
| 594 |
case KEY_8: digit = 8; break; |
| 595 |
case KEY_9: digit = 9; break; |
| 596 |
case KEY_SIGMA: digit = 10; break; |
| 597 |
case KEY_INV: digit = 11; break; |
| 598 |
case KEY_SQRT: digit = 12; break; |
| 599 |
case KEY_LOG: digit = 13; break; |
| 600 |
case KEY_LN: digit = 14; break; |
| 601 |
case KEY_XEQ: digit = 15; break; |
| 602 |
} |
| 603 |
if (digit >= base) |
| 604 |
return; |
| 605 |
if (core_settings.auto_repeat) { |
| 606 |
repeating = 2; |
| 607 |
repeating_key = key; |
| 608 |
repeating_shift = shift; |
| 609 |
} |
| 610 |
c = digit < 10 ? '0' + digit : 'A' + digit - 10; |
| 611 |
cmdline[cmdline_length++] = c; |
| 612 |
if (base == 10) { |
| 613 |
if (string2phloat(cmdline, cmdline_length, &x) == 0) { |
| 614 |
if (!flags.f.prgm_mode) |
| 615 |
fix_thousands_separators(cmdline, &cmdline_length); |
| 616 |
} else { |
| 617 |
cmdline_length--; |
| 618 |
return; |
| 619 |
} |
| 620 |
} else { |
| 621 |
bool zero = true; |
| 622 |
int bits = 0; |
| 623 |
int bits_per_digit = base == 2 ? 1 : base == 8 ? 3 : 4; |
| 624 |
for (int i = 0; i < cmdline_length; i++) { |
| 625 |
char c = cmdline[i]; |
| 626 |
if (c == ' ') |
| 627 |
continue; |
| 628 |
if (!zero) { |
| 629 |
bits += bits_per_digit; |
| 630 |
continue; |
| 631 |
} |
| 632 |
int d = c < 'A' ? c - '0' : c - 'A' + 10; |
| 633 |
if (d >= 8) |
| 634 |
bits = 4; |
| 635 |
else if (d >= 4) |
| 636 |
bits = 3; |
| 637 |
else if (d >= 2) |
| 638 |
bits = 2; |
| 639 |
else |
| 640 |
bits = d; |
| 641 |
zero = false; |
| 642 |
} |
| 643 |
if (bits > effective_wsize()) { |
| 644 |
cmdline_length--; |
| 645 |
return; |
| 646 |
} |
| 647 |
fix_base_separators(cmdline, &cmdline_length); |
| 648 |
} |
| 649 |
} |
| 650 |
|
| 651 |
if (base == 10) { |
| 652 |
if (string2phloat(cmdline, cmdline_length, &x) != 0) |
| 653 |
/* Should never happen */ |
| 654 |
x = 0; |
| 655 |
} else { |
| 656 |
uint8 n = 0; |
| 657 |
int i; |
| 658 |
for (i = 0; i < cmdline_length; i++) { |
| 659 |
char c = cmdline[i]; |
| 660 |
if (c == ' ') |
| 661 |
continue; |
| 662 |
int digit = c <= '9' ? c - '0' : c - 'A' + 10; |
| 663 |
n = n * base + digit; |
| 664 |
} |
| 665 |
int wsize = effective_wsize(); |
| 666 |
if (!flags.f.base_signed) |
| 667 |
x = (phloat) n; |
| 668 |
else if ((n & (1ULL << (wsize - 1))) == 0) |
| 669 |
x = (phloat) n; |
| 670 |
else |
| 671 |
x = (phloat) (int8) (n | (-1LL << (wsize - 1))); |
| 672 |
} |
| 673 |
|
| 674 |
if (flags.f.prgm_mode) |
| 675 |
entered_number = x; |
| 676 |
else { |
| 677 |
free_vartype(stack[sp]); |
| 678 |
stack[sp] = new_real(x); |
| 679 |
} |
| 680 |
|
| 681 |
draw_number: |
| 682 |
|
| 683 |
bufptr = 0; |
| 684 |
if (flags.f.prgm_mode) { |
| 685 |
int line = pc2line(pc); |
| 686 |
if (line < 10) |
| 687 |
char2buf(buf, 100, &bufptr, '0'); |
| 688 |
bufptr += int2string(line, buf + bufptr, 100 - bufptr); |
| 689 |
char2buf(buf, 100, &bufptr, 6); |
| 690 |
} else { |
| 691 |
xlabel2buf(buf, 100, &bufptr); |
| 692 |
} |
| 693 |
string2buf(buf, 100, &bufptr, cmdline, cmdline_length); |
| 694 |
char2buf(buf, 100, &bufptr, '_'); |
| 695 |
|
| 696 |
clear_row(cmdline_row); |
| 697 |
if (bufptr <= 22) |
| 698 |
draw_string(0, cmdline_row, buf, bufptr); |
| 699 |
else { |
| 700 |
draw_char(0, cmdline_row, 26); |
| 701 |
draw_string(1, cmdline_row, buf + bufptr - 21, 21); |
| 702 |
} |
| 703 |
flush_display(); |
| 704 |
return; |
| 705 |
} |
| 706 |
|
| 707 |
void keydown_command_entry(int shift, int key) { |
| 708 |
if (mode_commandmenu == MENU_ST || mode_commandmenu == MENU_IND_ST) { |
| 709 |
int menukey; |
| 710 |
if (!shift && key == KEY_BSP) { |
| 711 |
pending_command = CMD_NULL; |
| 712 |
finish_command_entry(false); |
| 713 |
return; |
| 714 |
} |
| 715 |
if (key == KEY_EXIT) { |
| 716 |
pending_command = CMD_CANCELLED; |
| 717 |
finish_command_entry(false); |
| 718 |
return; |
| 719 |
} |
| 720 |
menukey = find_menu_key(key); |
| 721 |
if (!shift && ((menukey >= 0 && menukey <= 4) |
| 722 |
|| (menukey == 5 && mode_commandmenu == MENU_IND_ST))) { |
| 723 |
if (mode_commandmenu == MENU_IND_ST && menukey == 0) { |
| 724 |
incomplete_ind = true; |
| 725 |
incomplete_alpha = false; |
| 726 |
incomplete_maxdigits = 2; |
| 727 |
set_catalog_menu(CATSECT_REAL_ONLY); |
| 728 |
redisplay(); |
| 729 |
return; |
| 730 |
} |
| 731 |
if (mode_commandmenu == MENU_IND_ST) |
| 732 |
menukey--; |
| 733 |
pending_command = incomplete_command; |
| 734 |
pending_command_arg.type = |
| 735 |
incomplete_ind ? ARGTYPE_IND_STK : ARGTYPE_STK; |
| 736 |
pending_command_arg.val.stk = "LXYZT"[menukey]; |
| 737 |
finish_command_entry(true); |
| 738 |
return; |
| 739 |
} |
| 740 |
squeak(); |
| 741 |
return; |
| 742 |
} |
| 743 |
|
| 744 |
if (incomplete_command == CMD_LBL && incomplete_length == 0 |
| 745 |
&& mode_commandmenu != MENU_CATALOG) { |
| 746 |
/* LBL is weird. It's sort of like you have alpha and numeric |
| 747 |
* at the same time. When we're at length 0, we have to handle |
| 748 |
* both possibilities and pick the right one. |
| 749 |
*/ |
| 750 |
if ((mode_commandmenu == MENU_ALPHA1 || mode_commandmenu == MENU_ALPHA2) |
| 751 |
&& key >= 1024 + '0' && key <= 1024 + '9') |
| 752 |
switch (key - 1024) { |
| 753 |
case '0': key = KEY_0; break; |
| 754 |
case '1': key = KEY_1; break; |
| 755 |
case '2': key = KEY_2; break; |
| 756 |
case '3': key = KEY_3; break; |
| 757 |
case '4': key = KEY_4; break; |
| 758 |
case '5': key = KEY_5; break; |
| 759 |
case '6': key = KEY_6; break; |
| 760 |
case '7': key = KEY_7; break; |
| 761 |
case '8': key = KEY_8; break; |
| 762 |
case '9': key = KEY_9; break; |
| 763 |
} |
| 764 |
|
| 765 |
if (key >= 1024 && key < 2048 |
| 766 |
|| (key == KEY_SIGMA || key == KEY_INV || key == KEY_SQRT |
| 767 |
|| key == KEY_LOG || key == KEY_LN || key == KEY_XEQ) |
| 768 |
|| (!shift && |
| 769 |
(key == KEY_E || key == KEY_UP || key == KEY_DOWN |
| 770 |
|| key == KEY_DIV || key == KEY_MUL || key == KEY_SUB |
| 771 |
|| key == KEY_ADD || key == KEY_DOT)) |
| 772 |
|| (shift && |
| 773 |
(key == KEY_RCL || key == KEY_RDN)) |
| 774 |
|| (mode_commandmenu >= MENU_ALPHA_ABCDE1 && |
| 775 |
mode_commandmenu <= MENU_ALPHA_MISC2 && ( |
| 776 |
key == KEY_0 || key == KEY_1 || key == KEY_2 |
| 777 |
|| key == KEY_3 || key == KEY_4 || key == KEY_5 |
| 778 |
|| key == KEY_6 || key == KEY_7 || key == KEY_8 |
| 779 |
|| key == KEY_9))) |
| 780 |
goto do_incomplete_alpha; |
| 781 |
if (shift && key == KEY_ADD) { |
| 782 |
if (mode_commandmenu == MENU_CATALOG) |
| 783 |
squeak(); |
| 784 |
else { |
| 785 |
incomplete_alpha = true; |
| 786 |
set_catalog_menu(CATSECT_TOP); |
| 787 |
redisplay(); |
| 788 |
} |
| 789 |
return; |
| 790 |
} |
| 791 |
if (key == KEY_EXIT && mode_commandmenu >= MENU_ALPHA_ABCDE1 |
| 792 |
&& mode_commandmenu <= MENU_ALPHA_MISC2) { |
| 793 |
if (mode_commandmenu <= MENU_ALPHA_WXYZ) |
| 794 |
mode_commandmenu = MENU_ALPHA1; |
| 795 |
else |
| 796 |
mode_commandmenu = MENU_ALPHA2; |
| 797 |
redisplay(); |
| 798 |
return; |
| 799 |
} |
| 800 |
} |
| 801 |
|
| 802 |
if (incomplete_command == CMD_LBL && !incomplete_alpha && incomplete_length == 1 |
| 803 |
&& shift && key == KEY_ENTER) { |
| 804 |
/* More LBL weirdness: you can switch to ALPHA mode while entering |
| 805 |
* a numeric LBL |
| 806 |
*/ |
| 807 |
incomplete_alpha = true; |
| 808 |
incomplete_str[0] = '0' + incomplete_num; |
| 809 |
incomplete_num = 0; |
| 810 |
mode_commandmenu = MENU_ALPHA1; |
| 811 |
redisplay(); |
| 812 |
return; |
| 813 |
} |
| 814 |
|
| 815 |
if ((incomplete_command == CMD_ASTO || incomplete_command == CMD_ARCL) |
| 816 |
&& mode_commandmenu == MENU_NONE |
| 817 |
&& mode_alphamenu >= MENU_ALPHA1 && mode_alphamenu <= MENU_ALPHA_MISC2) { |
| 818 |
/* ASTO and ARCL in ALPHA mode: When no variables menu is shown, either |
| 819 |
* because one digit has already been typed, or because no variables |
| 820 |
* exist, you can type digits for a numeric argument, even though the |
| 821 |
* ALPHA menu is active. Note that this behaves similarly to LBL, but |
| 822 |
* different. |
| 823 |
*/ |
| 824 |
switch (key - 1024) { |
| 825 |
case '0': key = KEY_0; break; |
| 826 |
case '1': key = KEY_1; break; |
| 827 |
case '2': key = KEY_2; break; |
| 828 |
case '3': key = KEY_3; break; |
| 829 |
case '4': key = KEY_4; break; |
| 830 |
case '5': key = KEY_5; break; |
| 831 |
case '6': key = KEY_6; break; |
| 832 |
case '7': key = KEY_7; break; |
| 833 |
case '8': key = KEY_8; break; |
| 834 |
case '9': key = KEY_9; break; |
| 835 |
} |
| 836 |
} |
| 837 |
|
| 838 |
|
| 839 |
/* Another oddity: ASSIGN... */ |
| 840 |
if (incomplete_argtype == ARG_CKEY) { |
| 841 |
int menukey = find_menu_key(key); |
| 842 |
if (menukey != -1) { |
| 843 |
pending_command = CMD_ASGN01 + menukey |
| 844 |
+ 6 * (mode_commandmenu - MENU_CUSTOM1); |
| 845 |
finish_command_entry(true); |
| 846 |
} else if (!shift && key == KEY_BSP) { |
| 847 |
pending_command = CMD_NULL; |
| 848 |
finish_command_entry(false); |
| 849 |
} else if (key == KEY_EXIT) { |
| 850 |
pending_command = CMD_CANCELLED; |
| 851 |
finish_command_entry(false); |
| 852 |
} else if (!shift && (key == KEY_UP || key == KEY_DOWN)) { |
| 853 |
mode_commandmenu += key == KEY_UP ? -1 : 1; |
| 854 |
if (mode_commandmenu < MENU_CUSTOM1) |
| 855 |
set_menu(MENULEVEL_COMMAND, MENU_CUSTOM3); |
| 856 |
else if (mode_commandmenu > MENU_CUSTOM3) |
| 857 |
set_menu(MENULEVEL_COMMAND, MENU_CUSTOM1); |
| 858 |
redisplay(); |
| 859 |
} else |
| 860 |
squeak(); |
| 861 |
return; |
| 862 |
} |
| 863 |
|
| 864 |
/* And yet another oddity: KEYG and KEYX */ |
| 865 |
if (incomplete_argtype == ARG_MKEY) { |
| 866 |
int cmd = incomplete_command == CMD_KEYG ? CMD_KEY1G : CMD_KEY1X; |
| 867 |
if (shift) { |
| 868 |
squeak(); |
| 869 |
return; |
| 870 |
} |
| 871 |
switch (key) { |
| 872 |
case KEY_SIGMA: case KEY_1: break; |
| 873 |
case KEY_INV: case KEY_2: cmd++; break; |
| 874 |
case KEY_SQRT: case KEY_3: cmd += 2; break; |
| 875 |
case KEY_LOG: case KEY_4: cmd += 3; break; |
| 876 |
case KEY_LN: case KEY_5: cmd += 4; break; |
| 877 |
case KEY_XEQ: case KEY_6: cmd += 5; break; |
| 878 |
case KEY_UP: case KEY_7: cmd += 6; break; |
| 879 |
case KEY_DOWN: case KEY_8: cmd += 7; break; |
| 880 |
case KEY_EXIT: case KEY_9: cmd += 8; break; |
| 881 |
case KEY_BSP: |
| 882 |
pending_command = CMD_NULL; |
| 883 |
finish_command_entry(false); |
| 884 |
return; |
| 885 |
default: |
| 886 |
squeak(); |
| 887 |
return; |
| 888 |
} |
| 889 |
start_incomplete_command(cmd); |
| 890 |
return; |
| 891 |
} |
| 892 |
|
| 893 |
if (mode_commandmenu == MENU_CATALOG) { |
| 894 |
int menukey = find_menu_key(key); |
| 895 |
int catsect = get_cat_section(); |
| 896 |
if (menukey != -1) { |
| 897 |
if (catsect == CATSECT_TOP) { |
| 898 |
switch (menukey) { |
| 899 |
case 0: |
| 900 |
set_cat_section(CATSECT_FCN); |
| 901 |
move_cat_row(0); |
| 902 |
break; |
| 903 |
case 1: |
| 904 |
set_cat_section(CATSECT_PGM); |
| 905 |
move_cat_row(0); |
| 906 |
break; |
| 907 |
case 2: |
| 908 |
if (!vars_exist(CATSECT_REAL)) { |
| 909 |
squeak(); |
| 910 |
return; |
| 911 |
} else { |
| 912 |
set_cat_section(CATSECT_REAL); |
| 913 |
move_cat_row(0); |
| 914 |
break; |
| 915 |
} |
| 916 |
case 3: |
| 917 |
if (!vars_exist(CATSECT_CPX)) { |
| 918 |
squeak(); |
| 919 |
return; |
| 920 |
} else { |
| 921 |
set_cat_section(CATSECT_CPX); |
| 922 |
move_cat_row(0); |
| 923 |
break; |
| 924 |
} |
| 925 |
case 4: |
| 926 |
if (!vars_exist(CATSECT_MAT)) { |
| 927 |
squeak(); |
| 928 |
return; |
| 929 |
} else { |
| 930 |
set_cat_section(CATSECT_MAT); |
| 931 |
move_cat_row(0); |
| 932 |
break; |
| 933 |
} |
| 934 |
case 5: display_mem(); |
| 935 |
pending_command = CMD_LINGER1; |
| 936 |
shell_request_timeout3(2000); |
| 937 |
return; |
| 938 |
} |
| 939 |
redisplay(); |
| 940 |
return; |
| 941 |
} else if (catsect == CATSECT_EXT_1) { |
| 942 |
switch (menukey) { |
| 943 |
case 0: set_cat_section(CATSECT_EXT_TIME); break; |
| 944 |
case 1: set_cat_section(CATSECT_EXT_XFCN); break; |
| 945 |
case 2: set_cat_section(CATSECT_EXT_BASE); break; |
| 946 |
case 3: set_cat_section(CATSECT_EXT_PRGM); break; |
| 947 |
case 4: set_cat_section(CATSECT_EXT_STR); break; |
| 948 |
case 5: set_cat_section(CATSECT_EXT_STK); break; |
| 949 |
} |
| 950 |
move_cat_row(0); |
| 951 |
redisplay(); |
| 952 |
return; |
| 953 |
} else if (catsect == CATSECT_EXT_2) { |
| 954 |
switch (menukey) { |
| 955 |
case 0: set_cat_section(CATSECT_EXT_STAT); break; |
| 956 |
case 1: set_cat_section(CATSECT_EXT_MISC); break; |
| 957 |
default: |
| 958 |
squeak(); |
| 959 |
return; |
| 960 |
} |
| 961 |
move_cat_row(0); |
| 962 |
redisplay(); |
| 963 |
return; |
| 964 |
} else { |
| 965 |
int i, itemindex; |
| 966 |
itemindex = get_cat_item(menukey); |
| 967 |
if (itemindex == -1) { |
| 968 |
squeak(); |
| 969 |
return; |
| 970 |
} else if (itemindex < 0) { |
| 971 |
set_cat_section(itemindex == -2 ? CATSECT_EXT_0_CMP : CATSECT_EXT_X_CMP); |
| 972 |
move_cat_row(0); |
| 973 |
redisplay(); |
| 974 |
return; |
| 975 |
} |
| 976 |
if (catsect == CATSECT_PGM || catsect == CATSECT_PGM_ONLY) { |
| 977 |
if (labels[itemindex].length == 0) { |
| 978 |
/* END or .END. */ |
| 979 |
if (incomplete_command != CMD_GTODOT |
| 980 |
&& incomplete_command != CMD_PRP |
| 981 |
&& (flags.f.prgm_mode |
| 982 |
|| (incomplete_command != CMD_GTO |
| 983 |
&& incomplete_command != CMD_XEQ |
| 984 |
&& incomplete_command != CMD_CLP))) { |
| 985 |
squeak(); |
| 986 |
return; |
| 987 |
} |
| 988 |
} |
| 989 |
pending_command = incomplete_command; |
| 990 |
if (incomplete_command == CMD_GTO |
| 991 |
|| incomplete_command == CMD_GTODOT |
| 992 |
|| incomplete_command == CMD_XEQ |
| 993 |
|| incomplete_command == CMD_CLP |
| 994 |
|| incomplete_command == CMD_PRP) { |
| 995 |
pending_command_arg.type = ARGTYPE_LBLINDEX; |
| 996 |
pending_command_arg.val.num = itemindex; |
| 997 |
xeq_invisible = 0; |
| 998 |
} else { |
| 999 |
pending_command_arg.type = |
| 1000 |
incomplete_ind ? ARGTYPE_IND_STR : ARGTYPE_STR; |
| 1001 |
pending_command_arg.length = |
| 1002 |
labels[itemindex].length; |
| 1003 |
for (i = 0; i < pending_command_arg.length; i++) |
| 1004 |
pending_command_arg.val.text[i] = |
| 1005 |
labels[itemindex].name[i]; |
| 1006 |
} |
| 1007 |
finish_command_entry(true); |
| 1008 |
return; |
| 1009 |
} |
| 1010 |
pending_command = incomplete_command; |
| 1011 |
pending_command_arg.type = |
| 1012 |
incomplete_ind ? ARGTYPE_IND_STR : ARGTYPE_STR; |
| 1013 |
if (catsect == CATSECT_FCN |
| 1014 |
|| catsect >= CATSECT_EXT_TIME && catsect <= CATSECT_EXT_MISC) { |
| 1015 |
const command_spec *cs = &cmd_array[itemindex]; |
| 1016 |
pending_command_arg.length = cs->name_length; |
| 1017 |
for (i = 0; i < pending_command_arg.length; i++) |
| 1018 |
pending_command_arg.val.text[i] = cs->name[i]; |
| 1019 |
} else { |
| 1020 |
pending_command_arg.length = vars[itemindex].length; |
| 1021 |
for (i = 0; i < pending_command_arg.length; i++) |
| 1022 |
pending_command_arg.val.text[i] = |
| 1023 |
vars[itemindex].name[i]; |
| 1024 |
} |
| 1025 |
|
| 1026 |
if (!incomplete_ind |
| 1027 |
&& (pending_command == CMD_GTO |
| 1028 |
|| pending_command == CMD_XEQ |
| 1029 |
|| pending_command == CMD_LBL |
| 1030 |
|| (pending_command >= CMD_KEY1G |
| 1031 |
&& pending_command <= CMD_KEY9X)) |
| 1032 |
&& pending_command_arg.length == 1 |
| 1033 |
&& ((pending_command_arg.val.text[0] >= 'A' |
| 1034 |
&& pending_command_arg.val.text[0] <= 'J') |
| 1035 |
|| (pending_command_arg.val.text[0] >= 'a' |
| 1036 |
&& pending_command_arg.val.text[0] <= 'e'))) { |
| 1037 |
/* Display XEQ "A" briefly before changing to XEQ A */ |
| 1038 |
mode_command_entry = false; |
| 1039 |
if (flags.f.prgm_mode) { |
| 1040 |
flags.f.prgm_mode = 0; |
| 1041 |
redisplay(); |
| 1042 |
flags.f.prgm_mode = 1; |
| 1043 |
shell_delay(125); |
| 1044 |
} else |
| 1045 |
redisplay(); |
| 1046 |
pending_command_arg.type = ARGTYPE_LCLBL; |
| 1047 |
pending_command_arg.val.lclbl = pending_command_arg.val.text[0]; |
| 1048 |
finish_command_entry(false); |
| 1049 |
return; |
| 1050 |
} |
| 1051 |
|
| 1052 |
if (!incomplete_ind && incomplete_command == CMD_XEQ) |
| 1053 |
finish_xeq(); |
| 1054 |
else |
| 1055 |
finish_command_entry(true); |
| 1056 |
return; |
| 1057 |
} |
| 1058 |
} |
| 1059 |
if (!shift && (key == KEY_UP || key == KEY_DOWN)) { |
| 1060 |
move_cat_row(key == KEY_UP ? -1 : 1); |
| 1061 |
redisplay(); |
| 1062 |
return; |
| 1063 |
} |
| 1064 |
if (key == KEY_EXIT) { |
| 1065 |
if (catsect == CATSECT_FCN |
| 1066 |
|| catsect == CATSECT_PGM |
| 1067 |
|| catsect == CATSECT_REAL |
| 1068 |
|| catsect == CATSECT_CPX |
| 1069 |
|| catsect == CATSECT_MAT) { |
| 1070 |
set_cat_section(CATSECT_TOP); |
| 1071 |
redisplay(); |
| 1072 |
} else if (catsect == CATSECT_EXT_TIME |
| 1073 |
|| catsect == CATSECT_EXT_XFCN |
| 1074 |
|| catsect == CATSECT_EXT_BASE |
| 1075 |
|| catsect == CATSECT_EXT_PRGM |
| 1076 |
|| catsect == CATSECT_EXT_STR |
| 1077 |
|| catsect == CATSECT_EXT_STK) { |
| 1078 |
set_cat_section(CATSECT_EXT_1); |
| 1079 |
redisplay(); |
| 1080 |
} else if (catsect == CATSECT_EXT_STAT |
| 1081 |
|| catsect == CATSECT_EXT_MISC) { |
| 1082 |
set_cat_section(CATSECT_EXT_2); |
| 1083 |
redisplay(); |
| 1084 |
} else if (catsect == CATSECT_EXT_0_CMP |
| 1085 |
|| catsect == CATSECT_EXT_X_CMP) { |
| 1086 |
set_cat_section(CATSECT_EXT_PRGM); |
| 1087 |
set_cat_row(3); |
| 1088 |
redisplay(); |
| 1089 |
} else { |
| 1090 |
pending_command = CMD_CANCELLED; |
| 1091 |
finish_command_entry(false); |
| 1092 |
} |
| 1093 |
return; |
| 1094 |
} |
| 1095 |
} |
| 1096 |
|
| 1097 |
if (mode_commandmenu == MENU_VARMENU) { |
| 1098 |
int menukey = find_menu_key(key); |
| 1099 |
if (menukey != -1) { |
| 1100 |
int i; |
| 1101 |
if (varmenu_labellength[menukey] == 0) { |
| 1102 |
squeak(); |
| 1103 |
return; |
| 1104 |
} |
| 1105 |
pending_command = incomplete_command; |
| 1106 |
pending_command_arg.type = ARGTYPE_STR; |
| 1107 |
pending_command_arg.length = varmenu_labellength[menukey]; |
| 1108 |
for (i = 0; i < pending_command_arg.length; i++) |
| 1109 |
pending_command_arg.val.text[i] = |
| 1110 |
varmenu_labeltext[menukey][i]; |
| 1111 |
finish_command_entry(false); |
| 1112 |
return; |
| 1113 |
} |
| 1114 |
if (!shift && (key == KEY_UP || key == KEY_DOWN)) { |
| 1115 |
if (varmenu_rows > 1) { |
| 1116 |
if (key == KEY_UP) { |
| 1117 |
varmenu_row--; |
| 1118 |
if (varmenu_row < 0) |
| 1119 |
varmenu_row = varmenu_rows - 1; |
| 1120 |
} else { |
| 1121 |
varmenu_row++; |
| 1122 |
if (varmenu_row >= varmenu_rows) |
| 1123 |
varmenu_row = 0; |
| 1124 |
} |
| 1125 |
redisplay(); |
| 1126 |
} |
| 1127 |
return; |
| 1128 |
} |
| 1129 |
if (key == KEY_EXIT) { |
| 1130 |
pending_command = CMD_CANCELLED; |
| 1131 |
finish_command_entry(false); |
| 1132 |
return; |
| 1133 |
} |
| 1134 |
} else if (mode_commandmenu == MENU_INTEG_PARAMS) { |
| 1135 |
int menukey = find_menu_key(key); |
| 1136 |
if (menukey != -1) { |
| 1137 |
const char *name; |
| 1138 |
int length, i; |
| 1139 |
switch (menukey) { |
| 1140 |
case 0: name = "LLIM"; length = 4; break; |
| 1141 |
case 1: name = "ULIM"; length = 4; break; |
| 1142 |
case 2: name = "ACC"; length = 3; break; |
| 1143 |
default: squeak(); return; |
| 1144 |
} |
| 1145 |
pending_command = incomplete_command; |
| 1146 |
pending_command_arg.type = ARGTYPE_STR; |
| 1147 |
pending_command_arg.length = length; |
| 1148 |
for (i = 0; i < length; i++) |
| 1149 |
pending_command_arg.val.text[i] = name[i]; |
| 1150 |
finish_command_entry(false); |
| 1151 |
return; |
| 1152 |
} |
| 1153 |
if (key == KEY_EXIT) { |
| 1154 |
pending_command = CMD_CANCELLED; |
| 1155 |
finish_command_entry(false); |
| 1156 |
return; |
| 1157 |
} |
| 1158 |
} |
| 1159 |
|
| 1160 |
if (!incomplete_alpha) { |
| 1161 |
if (key == KEY_EXIT) { |
| 1162 |
pending_command = CMD_CANCELLED; |
| 1163 |
finish_command_entry(false); |
| 1164 |
return; |
| 1165 |
} |
| 1166 |
|
| 1167 |
if (mode_commandmenu == MENU_IND) { |
| 1168 |
if (!shift && key == KEY_SIGMA) { |
| 1169 |
incomplete_command = CMD_GTO; |
| 1170 |
incomplete_argtype = ARG_LBL; |
| 1171 |
incomplete_ind = true; |
| 1172 |
incomplete_maxdigits = 2; |
| 1173 |
set_catalog_menu(CATSECT_REAL_ONLY); |
| 1174 |
redisplay(); |
| 1175 |
return; |
| 1176 |
} else if (key == KEY_ENTER) { |
| 1177 |
incomplete_argtype = ARG_LBL; |
| 1178 |
incomplete_alpha = true; |
| 1179 |
set_menu(MENULEVEL_COMMAND, MENU_ALPHA1); |
| 1180 |
redisplay(); |
| 1181 |
return; |
| 1182 |
} |
| 1183 |
} |
| 1184 |
|
| 1185 |
if (incomplete_command == CMD_STO |
| 1186 |
&& !shift && incomplete_length == 0 |
| 1187 |
&& (key == KEY_DIV || key == KEY_MUL |
| 1188 |
|| key == KEY_SUB || key == KEY_ADD)) { |
| 1189 |
switch (key) { |
| 1190 |
case KEY_DIV: incomplete_command = CMD_STO_DIV; break; |
| 1191 |
case KEY_MUL: incomplete_command = CMD_STO_MUL; break; |
| 1192 |
case KEY_SUB: incomplete_command = CMD_STO_SUB; break; |
| 1193 |
case KEY_ADD: incomplete_command = CMD_STO_ADD; break; |
| 1194 |
} |
| 1195 |
redisplay(); |
| 1196 |
return; |
| 1197 |
} |
| 1198 |
if (incomplete_command == CMD_RCL |
| 1199 |
&& !shift && incomplete_length == 0 |
| 1200 |
&& (key == KEY_DIV || key == KEY_MUL |
| 1201 |
|| key == KEY_SUB || key == KEY_ADD)) { |
| 1202 |
switch (key) { |
| 1203 |
case KEY_DIV: incomplete_command = CMD_RCL_DIV; break; |
| 1204 |
case KEY_MUL: incomplete_command = CMD_RCL_MUL; break; |
| 1205 |
case KEY_SUB: incomplete_command = CMD_RCL_SUB; break; |
| 1206 |
case KEY_ADD: incomplete_command = CMD_RCL_ADD; break; |
| 1207 |
} |
| 1208 |
redisplay(); |
| 1209 |
return; |
| 1210 |
} |
| 1211 |
if (incomplete_command == CMD_GTO |
| 1212 |
&& !incomplete_ind |
| 1213 |
&& !shift && incomplete_length == 0 |
| 1214 |
&& key == KEY_DOT) { |
| 1215 |
incomplete_command = CMD_GTODOT; |
| 1216 |
incomplete_argtype = ARG_OTHER; |
| 1217 |
incomplete_maxdigits = 4; |
| 1218 |
set_menu(MENULEVEL_COMMAND, MENU_IND); |
| 1219 |
redisplay(); |
| 1220 |
return; |
| 1221 |
} |
| 1222 |
if (incomplete_command == CMD_GTODOT |
| 1223 |
&& !shift && incomplete_length == 0 |
| 1224 |
&& key == KEY_DOT) { |
| 1225 |
pending_command = CMD_GTODOTDOT; |
| 1226 |
pending_command_arg.type = ARGTYPE_NONE; |
| 1227 |
finish_command_entry(false); |
| 1228 |
return; |
| 1229 |
} |
| 1230 |
|
| 1231 |
|
| 1232 |
if (key == KEY_ENTER) { |
| 1233 |
if (incomplete_length == 0) { |
| 1234 |
if (incomplete_ind |
| 1235 |
&& !flags.f.prgm_mode |
| 1236 |
&& !vars_exist(CATSECT_REAL)) |
| 1237 |
squeak(); |
| 1238 |
else if (incomplete_ind |
| 1239 |
|| incomplete_argtype == ARG_VAR |
| 1240 |
|| incomplete_argtype == ARG_REAL |
| 1241 |
|| incomplete_argtype == ARG_NAMED |
| 1242 |
|| incomplete_argtype == ARG_LBL |
| 1243 |
|| incomplete_argtype == ARG_PRGM) { |
| 1244 |
incomplete_alpha = true; |
| 1245 |
set_menu(MENULEVEL_COMMAND, MENU_ALPHA1); |
| 1246 |
redisplay(); |
| 1247 |
} else |
| 1248 |
squeak(); |
| 1249 |
return; |
| 1250 |
} else if (!shift) { |
| 1251 |
if (incomplete_command == CMD_GOTOROW) { |
| 1252 |
pending_command_arg.val.num = incomplete_num; |
| 1253 |
vartype *m; |
| 1254 |
int err = matedit_get(&m); |
| 1255 |
if (err == ERR_NONE && m->type == TYPE_LIST) { |
| 1256 |
incomplete_num = 1; |
| 1257 |
goto do_goto1; |
| 1258 |
} |
| 1259 |
if ((flags.f.trace_print || flags.f.normal_print) && flags.f.printer_exists) { |
| 1260 |
arg_struct arg; |
| 1261 |
arg.type = ARGTYPE_NUM; |
| 1262 |
arg.val.num = incomplete_num; |
| 1263 |
print_command(CMD_GOTOROW, &arg); |
| 1264 |
} |
| 1265 |
start_incomplete_command(CMD_GOTOCOLUMN); |
| 1266 |
return; |
| 1267 |
} else if (incomplete_command == CMD_GOTOCOLUMN) { |
| 1268 |
do_goto1: |
| 1269 |
if ((flags.f.trace_print || flags.f.normal_print) && flags.f.printer_exists) { |
| 1270 |
arg_struct arg; |
| 1271 |
arg.type = ARGTYPE_NUM; |
| 1272 |
arg.val.num = incomplete_num; |
| 1273 |
print_command(CMD_GOTOCOLUMN, &arg); |
| 1274 |
} |
| 1275 |
matedit_goto(pending_command_arg.val.num, incomplete_num); |
| 1276 |
pending_command = CMD_NONE; |
| 1277 |
finish_command_entry(true); |
| 1278 |
return; |
| 1279 |
} |
| 1280 |
pending_command = incomplete_command; |
| 1281 |
pending_command_arg.type = |
| 1282 |
incomplete_ind ? ARGTYPE_IND_NUM : ARGTYPE_NUM; |
| 1283 |
pending_command_arg.length = incomplete_maxdigits; |
| 1284 |
pending_command_arg.val.num = incomplete_num; |
| 1285 |
finish_command_entry(false); |
| 1286 |
return; |
| 1287 |
} |
| 1288 |
} |
| 1289 |
|
| 1290 |
if (incomplete_length == 0 && !shift && key == KEY_DOT) { |
| 1291 |
if (incomplete_ind) { |
| 1292 |
if (incomplete_argtype == ARG_VAR |
| 1293 |
|| incomplete_argtype == ARG_REAL |
| 1294 |
|| incomplete_argtype == ARG_MAT |
| 1295 |
|| incomplete_argtype == ARG_M_STK |
| 1296 |
|| incomplete_argtype == ARG_L_STK |
| 1297 |
|| incomplete_argtype == ARG_RVAR |
| 1298 |
|| incomplete_argtype == ARG_NAMED |
| 1299 |
|| incomplete_argtype == ARG_LBL |
| 1300 |
|| incomplete_argtype == ARG_PRGM |
| 1301 |
|| incomplete_argtype == ARG_NUM9 |
| 1302 |
|| incomplete_argtype == ARG_NUM11 |
| 1303 |
|| incomplete_argtype == ARG_NUM99) { |
| 1304 |
set_menu(MENULEVEL_COMMAND, MENU_ST); |
| 1305 |
redisplay(); |
| 1306 |
} |
| 1307 |
} else { |
| 1308 |
if (incomplete_argtype == ARG_VAR |
| 1309 |
|| incomplete_argtype == ARG_REAL) { |
| 1310 |
set_menu(MENULEVEL_COMMAND, MENU_IND_ST); |
| 1311 |
redisplay(); |
| 1312 |
} else if (incomplete_argtype == ARG_NUM9 |
| 1313 |
|| incomplete_argtype == ARG_NUM11 |
| 1314 |
|| incomplete_argtype == ARG_NUM99 |
| 1315 |
|| incomplete_argtype == ARG_LBL) { |
| 1316 |
incomplete_ind = true; |
| 1317 |
incomplete_maxdigits = 2; |
| 1318 |
set_catalog_menu(CATSECT_REAL_ONLY); |
| 1319 |
redisplay(); |
| 1320 |
} else { |
| 1321 |
squeak(); |
| 1322 |
} |
| 1323 |
} |
| 1324 |
return; |
| 1325 |
} |
| 1326 |
|
| 1327 |
if (incomplete_length < incomplete_maxdigits && !shift && |
| 1328 |
(key == KEY_0 || key == KEY_1 || key == KEY_2 |
| 1329 |
|| key == KEY_3 || key == KEY_4 || key == KEY_5 |
| 1330 |
|| key == KEY_6 || key == KEY_7 || key == KEY_8 |
| 1331 |
|| key == KEY_9)) { |
| 1332 |
int digit; |
| 1333 |
switch (key) { |
| 1334 |
case KEY_0: digit = 0; break; |
| 1335 |
case KEY_1: digit = 1; break; |
| 1336 |
case KEY_2: digit = 2; break; |
| 1337 |
case KEY_3: digit = 3; break; |
| 1338 |
case KEY_4: digit = 4; break; |
| 1339 |
case KEY_5: digit = 5; break; |
| 1340 |
case KEY_6: digit = 6; break; |
| 1341 |
case KEY_7: digit = 7; break; |
| 1342 |
case KEY_8: digit = 8; break; |
| 1343 |
case KEY_9: digit = 9; break; |
| 1344 |
} |
| 1345 |
if (incomplete_argtype == ARG_FUNC && digit > 4) { |
| 1346 |
squeak(); |
| 1347 |
return; |
| 1348 |
} |
| 1349 |
if (incomplete_command == CMD_RTNERR && !incomplete_ind && digit > 8) { |
| 1350 |
squeak(); |
| 1351 |
return; |
| 1352 |
} |
| 1353 |
incomplete_num = incomplete_num * 10 + digit; |
| 1354 |
incomplete_length++; |
| 1355 |
if (incomplete_length == incomplete_maxdigits) { |
| 1356 |
if (incomplete_command == CMD_GOTOROW) { |
| 1357 |
pending_command_arg.val.num = incomplete_num; |
| 1358 |
vartype *m; |
| 1359 |
int err = matedit_get(&m); |
| 1360 |
if (err == ERR_NONE && m->type == TYPE_LIST) { |
| 1361 |
incomplete_num = 1; |
| 1362 |
goto do_goto2; |
| 1363 |
} |
| 1364 |
if ((flags.f.trace_print || flags.f.normal_print) && flags.f.printer_exists) { |
| 1365 |
arg_struct arg; |
| 1366 |
arg.type = ARGTYPE_NUM; |
| 1367 |
arg.val.num = incomplete_num; |
| 1368 |
print_command(CMD_GOTOROW, &arg); |
| 1369 |
} |
| 1370 |
start_incomplete_command(CMD_GOTOCOLUMN); |
| 1371 |
return; |
| 1372 |
} else if (incomplete_command == CMD_GOTOCOLUMN) { |
| 1373 |
do_goto2: |
| 1374 |
if ((flags.f.trace_print || flags.f.normal_print) && flags.f.printer_exists) { |
| 1375 |
arg_struct arg; |
| 1376 |
arg.type = ARGTYPE_NUM; |
| 1377 |
arg.val.num = incomplete_num; |
| 1378 |
print_command(CMD_GOTOCOLUMN, &arg); |
| 1379 |
} |
| 1380 |
matedit_goto(pending_command_arg.val.num, incomplete_num); |
| 1381 |
pending_command = CMD_NONE; |
| 1382 |
finish_command_entry(true); |
| 1383 |
return; |
| 1384 |
} |
| 1385 |
pending_command = incomplete_command; |
| 1386 |
pending_command_arg.type = |
| 1387 |
incomplete_ind ? ARGTYPE_IND_NUM : ARGTYPE_NUM; |
| 1388 |
pending_command_arg.length = incomplete_maxdigits; |
| 1389 |
if (!incomplete_ind && |
| 1390 |
incomplete_argtype == ARG_NUM11 && incomplete_num > 11) |
| 1391 |
incomplete_num = 11; |
| 1392 |
pending_command_arg.val.num = incomplete_num; |
| 1393 |
finish_command_entry(true); |
| 1394 |
return; |
| 1395 |
} else |
| 1396 |
set_menu(MENULEVEL_COMMAND, MENU_NONE); |
| 1397 |
redisplay(); |
| 1398 |
return; |
| 1399 |
} |
| 1400 |
|
| 1401 |
if (incomplete_length < incomplete_maxdigits |
| 1402 |
&& !shift && key == KEY_BSP) { |
| 1403 |
if (incomplete_length == 0) { |
| 1404 |
pending_command = CMD_NULL; |
| 1405 |
finish_command_entry(false); |
| 1406 |
return; |
| 1407 |
} else { |
| 1408 |
incomplete_length--; |
| 1409 |
incomplete_num /= 10; |
| 1410 |
if (incomplete_length == 0) { |
| 1411 |
if (incomplete_command >= CMD_KEY1G |
| 1412 |
&& incomplete_command <= CMD_KEY9X) |
| 1413 |
start_incomplete_command( |
| 1414 |
incomplete_command <= CMD_KEY9G ? CMD_KEYG |
| 1415 |
: CMD_KEYX); |
| 1416 |
else if (incomplete_argtype == ARG_VAR) |
| 1417 |
if (mode_appmenu == MENU_VARMENU) |
| 1418 |
set_menu(MENULEVEL_COMMAND, MENU_VARMENU); |
| 1419 |
else if (mode_appmenu == MENU_INTEG_PARAMS) |
| 1420 |
set_menu(MENULEVEL_COMMAND, MENU_INTEG_PARAMS); |
| 1421 |
else |
| 1422 |
set_catalog_menu(CATSECT_VARS_ONLY); |
| 1423 |
else if (incomplete_ind) |
| 1424 |
set_catalog_menu(CATSECT_REAL_ONLY); |
| 1425 |
else if (incomplete_argtype == ARG_REAL) |
| 1426 |
if (mode_appmenu == MENU_VARMENU) |
| 1427 |
set_menu(MENULEVEL_COMMAND, MENU_VARMENU); |
| 1428 |
else if (mode_appmenu == MENU_INTEG_PARAMS) |
| 1429 |
set_menu(MENULEVEL_COMMAND, MENU_INTEG_PARAMS); |
| 1430 |
else |
| 1431 |
set_catalog_menu(CATSECT_REAL_ONLY); |
| 1432 |
else if (incomplete_argtype == ARG_LBL) |
| 1433 |
set_catalog_menu(CATSECT_PGM_ONLY); |
| 1434 |
else if (incomplete_command == CMD_GTODOT) |
| 1435 |
set_menu(MENULEVEL_COMMAND, MENU_IND); |
| 1436 |
else if (incomplete_command == CMD_LBL) |
| 1437 |
set_menu(MENULEVEL_COMMAND, MENU_ALPHA1); |
| 1438 |
} |
| 1439 |
redisplay(); |
| 1440 |
return; |
| 1441 |
} |
| 1442 |
} |
| 1443 |
|
| 1444 |
/* Some bad key... */ |
| 1445 |
squeak(); |
| 1446 |
return; |
| 1447 |
|
| 1448 |
} else { |
| 1449 |
/* incomplete_alpha */ |
| 1450 |
|
| 1451 |
int menukey; |
| 1452 |
const menu_spec *m; |
| 1453 |
char c; |
| 1454 |
|
| 1455 |
do_incomplete_alpha: |
| 1456 |
m = NULL; |
| 1457 |
|
| 1458 |
if (key >= 1024 && key < 2048) { |
| 1459 |
c = key - 1024; |
| 1460 |
goto handle_char; |
| 1461 |
} else if (mode_commandmenu != MENU_NONE |
| 1462 |
&& (menukey = find_menu_key(key)) != -1) { |
| 1463 |
const menu_item_spec *mi; |
| 1464 |
m = menus + mode_commandmenu; |
| 1465 |
mi = m->child + menukey; |
| 1466 |
if (mi->menuid != MENU_NONE) { |
| 1467 |
set_menu(MENULEVEL_COMMAND, mi->menuid); |
| 1468 |
redisplay(); |
| 1469 |
return; |
| 1470 |
} |
| 1471 |
c = mi->title[0]; |
| 1472 |
if (shift && c >= 'A' && c <= 'Z') |
| 1473 |
c += 'a' - 'A'; |
| 1474 |
handle_char: |
| 1475 |
if (incomplete_length < (incomplete_argtype == ARG_XSTR ? 22 : 7)) |
| 1476 |
incomplete_str[incomplete_length++] = c; |
| 1477 |
if (m != NULL) |
| 1478 |
set_menu(MENULEVEL_COMMAND, m->parent); |
| 1479 |
if (core_settings.auto_repeat) { |
| 1480 |
repeating = 2; |
| 1481 |
repeating_key = c + 1024; |
| 1482 |
repeating_shift = 0; |
| 1483 |
} |
| 1484 |
/* incomplete_alpha can be 0 at this point if |
| 1485 |
* the command is CMD_LBL. */ |
| 1486 |
incomplete_alpha = true; |
| 1487 |
redisplay(); |
| 1488 |
return; |
| 1489 |
} |
| 1490 |
|
| 1491 |
if ((incomplete_argtype == ARG_NAMED |
| 1492 |
|| incomplete_argtype == ARG_PRGM |
| 1493 |
|| incomplete_argtype == ARG_RVAR |
| 1494 |
|| incomplete_argtype == ARG_MAT) |
| 1495 |
&& incomplete_command != CMD_ASSIGNa |
| 1496 |
&& incomplete_command != CMD_CLP |
| 1497 |
&& incomplete_command != CMD_PRP |
| 1498 |
&& incomplete_command != CMD_MVAR |
| 1499 |
&& !incomplete_ind |
| 1500 |
&& incomplete_length == 0 |
| 1501 |
&& (mode_commandmenu < MENU_ALPHA1 |
| 1502 |
|| mode_commandmenu > MENU_ALPHA_MISC2) |
| 1503 |
&& !shift && key == KEY_DOT) { |
| 1504 |
incomplete_ind = true; |
| 1505 |
incomplete_alpha = false; |
| 1506 |
set_catalog_menu(CATSECT_REAL_ONLY); |
| 1507 |
redisplay(); |
| 1508 |
return; |
| 1509 |
} else if ((incomplete_argtype == ARG_M_STK |
| 1510 |
|| incomplete_argtype == ARG_L_STK) |
| 1511 |
&& !incomplete_ind |
| 1512 |
&& incomplete_length == 0 |
| 1513 |
&& (mode_commandmenu < MENU_ALPHA1 |
| 1514 |
|| mode_commandmenu > MENU_ALPHA_MISC2) |
| 1515 |
&& !shift && key == KEY_DOT) { |
| 1516 |
set_menu(MENULEVEL_COMMAND, MENU_IND_ST); |
| 1517 |
redisplay(); |
| 1518 |
return; |
| 1519 |
} |
| 1520 |
|
| 1521 |
if (shift && key == KEY_ADD) { |
| 1522 |
if (mode_commandmenu == MENU_CATALOG) |
| 1523 |
squeak(); |
| 1524 |
else { |
| 1525 |
set_catalog_menu(CATSECT_TOP); |
| 1526 |
redisplay(); |
| 1527 |
} |
| 1528 |
return; |
| 1529 |
} |
| 1530 |
|
| 1531 |
/* Handle keys that represent characters */ |
| 1532 |
if (mode_commandmenu == MENU_CATALOG) |
| 1533 |
goto nocharkey1; |
| 1534 |
if (!shift) { |
| 1535 |
switch (key) { |
| 1536 |
case KEY_0: c = '0'; break; |
| 1537 |
case KEY_1: c = '1'; break; |
| 1538 |
case KEY_2: c = '2'; break; |
| 1539 |
case KEY_3: c = '3'; break; |
| 1540 |
case KEY_4: c = '4'; break; |
| 1541 |
case KEY_5: c = '5'; break; |
| 1542 |
case KEY_6: c = '6'; break; |
| 1543 |
case KEY_7: c = '7'; break; |
| 1544 |
case KEY_8: c = '8'; break; |
| 1545 |
case KEY_9: c = '9'; break; |
| 1546 |
case KEY_DOT: c = '.'; break; |
| 1547 |
case KEY_E: c = 24; break; |
| 1548 |
case KEY_DIV: c = 0; break; |
| 1549 |
case KEY_MUL: c = 1; break; |
| 1550 |
case KEY_SUB: c = '-'; break; |
| 1551 |
case KEY_ADD: c = '+'; break; |
| 1552 |
default: goto nocharkey1; |
| 1553 |
} |
| 1554 |
} else { |
| 1555 |
switch (key) { |
| 1556 |
case KEY_RCL: c = '%'; break; |
| 1557 |
case KEY_RDN: c = 7; break; |
| 1558 |
default: goto nocharkey1; |
| 1559 |
} |
| 1560 |
} |
| 1561 |
if (incomplete_length < (incomplete_argtype == ARG_XSTR ? 22 : 7)) |
| 1562 |
incomplete_str[incomplete_length++] = c; |
| 1563 |
if (core_settings.auto_repeat) { |
| 1564 |
repeating = 2; |
| 1565 |
repeating_key = c + 1024; |
| 1566 |
repeating_shift = 0; |
| 1567 |
} |
| 1568 |
/* incomplete_alpha can be 0 at this point if |
| 1569 |
* the command is CMD_LBL. */ |
| 1570 |
incomplete_alpha = true; |
| 1571 |
redisplay(); |
| 1572 |
return; |
| 1573 |
nocharkey1: |
| 1574 |
/* End of handling keys that represent characters */ |
| 1575 |
|
| 1576 |
if (!shift && (key == KEY_UP || key == KEY_DOWN)) { |
| 1577 |
const menu_spec *m = menus + mode_commandmenu; |
| 1578 |
int nextmenu = key == KEY_UP ? m->prev : m->next; |
| 1579 |
if (nextmenu != MENU_NONE) { |
| 1580 |
set_menu(MENULEVEL_COMMAND, nextmenu); |
| 1581 |
redisplay(); |
| 1582 |
} |
| 1583 |
return; |
| 1584 |
} |
| 1585 |
|
| 1586 |
if (key == KEY_EXIT) { |
| 1587 |
const menu_spec *m; |
| 1588 |
if (mode_commandmenu == MENU_NONE) { |
| 1589 |
pending_command = CMD_CANCELLED; |
| 1590 |
finish_command_entry(false); |
| 1591 |
return; |
| 1592 |
} |
| 1593 |
if (mode_commandmenu == MENU_CATALOG) { |
| 1594 |
int catsect = get_cat_section(); |
| 1595 |
if (catsect == CATSECT_PGM |
| 1596 |
|| catsect == CATSECT_REAL |
| 1597 |
|| catsect == CATSECT_CPX |
| 1598 |
|| catsect == CATSECT_MAT) { |
| 1599 |
set_cat_section(CATSECT_TOP); |
| 1600 |
redisplay(); |
| 1601 |
return; |
| 1602 |
} |
| 1603 |
} |
| 1604 |
m = menus + mode_commandmenu; |
| 1605 |
set_menu(MENULEVEL_COMMAND, m->parent); |
| 1606 |
if (mode_commandmenu == MENU_NONE) { |
| 1607 |
pending_command = CMD_CANCELLED; |
| 1608 |
finish_command_entry(false); |
| 1609 |
} else |
| 1610 |
redisplay(); |
| 1611 |
return; |
| 1612 |
} |
| 1613 |
|
| 1614 |
if (!shift && key == KEY_BSP) { |
| 1615 |
if (incomplete_command >= CMD_KEY1G |
| 1616 |
&& incomplete_command <= CMD_KEY9X) { |
| 1617 |
if (incomplete_length == 0) { |
| 1618 |
if (mode_commandmenu >= MENU_ALPHA1 |
| 1619 |
&& mode_commandmenu <= MENU_ALPHA_MISC2) |
| 1620 |
start_incomplete_command( |
| 1621 |
incomplete_command <= CMD_KEY9G |
| 1622 |
? CMD_KEYG : CMD_KEYX); |
| 1623 |
else { |
| 1624 |
pending_command = CMD_NULL; |
| 1625 |
finish_command_entry(false); |
| 1626 |
} |
| 1627 |
} else { |
| 1628 |
incomplete_length--; |
| 1629 |
redisplay(); |
| 1630 |
} |
| 1631 |
return; |
| 1632 |
} |
| 1633 |
if (incomplete_length == 0) { |
| 1634 |
int catsect; |
| 1635 |
if (mode_commandmenu >= MENU_ALPHA1 |
| 1636 |
&& mode_commandmenu <= MENU_ALPHA_MISC2) { |
| 1637 |
if (incomplete_ind) |
| 1638 |
goto out_of_alpha; |
| 1639 |
if (incomplete_command == CMD_GTODOT) { |
| 1640 |
incomplete_argtype = ARG_OTHER; |
| 1641 |
incomplete_maxdigits = 4; |
| 1642 |
incomplete_alpha = false; |
| 1643 |
set_menu(MENULEVEL_COMMAND, MENU_IND); |
| 1644 |
redisplay(); |
| 1645 |
return; |
| 1646 |
} else if (incomplete_argtype == ARG_NAMED) { |
| 1647 |
if (incomplete_command == CMD_ASSIGNa) |
| 1648 |
set_catalog_menu(CATSECT_TOP); |
| 1649 |
else |
| 1650 |
set_catalog_menu(CATSECT_VARS_ONLY); |
| 1651 |
if (incomplete_ind) |
| 1652 |
goto out_of_alpha; |
| 1653 |
} else if (incomplete_argtype == ARG_RVAR) { |
| 1654 |
if (incomplete_command == CMD_MVAR) { |
| 1655 |
pending_command = CMD_NULL; |
| 1656 |
finish_command_entry(false); |
| 1657 |
} else |
| 1658 |
goto out_of_alpha; |
| 1659 |
} else if (incomplete_argtype == ARG_MAT) { |
| 1660 |
if (vars_exist(CATSECT_MAT_LIST)) |
| 1661 |
set_catalog_menu(CATSECT_MAT_LIST_ONLY); |
| 1662 |
else |
| 1663 |
set_menu(MENULEVEL_COMMAND, MENU_NONE); |
| 1664 |
} else if (incomplete_argtype == ARG_M_STK) { |
| 1665 |
if (vars_exist(CATSECT_MAT)) |
| 1666 |
set_catalog_menu(CATSECT_MAT_ONLY); |
| 1667 |
else |
| 1668 |
set_menu(MENULEVEL_COMMAND, MENU_NONE); |
| 1669 |
} else if (incomplete_argtype == ARG_L_STK) { |
| 1670 |
if (vars_exist(CATSECT_LIST)) |
| 1671 |
set_catalog_menu(CATSECT_LIST_ONLY); |
| 1672 |
else |
| 1673 |
set_menu(MENULEVEL_COMMAND, MENU_NONE); |
| 1674 |
} else if (incomplete_argtype == ARG_PRGM) |
| 1675 |
set_catalog_menu(CATSECT_PGM_ONLY); |
| 1676 |
else if (incomplete_argtype == ARG_XSTR) { |
| 1677 |
pending_command = CMD_NULL; |
| 1678 |
finish_command_entry(false); |
| 1679 |
} else |
| 1680 |
goto out_of_alpha; |
| 1681 |
redisplay(); |
| 1682 |
} else if (mode_commandmenu == MENU_CATALOG |
| 1683 |
&& ((catsect = get_cat_section()) == CATSECT_FCN |
| 1684 |
|| catsect == CATSECT_PGM |
| 1685 |
|| catsect == CATSECT_REAL |
| 1686 |
|| catsect == CATSECT_CPX |
| 1687 |
|| catsect == CATSECT_MAT)) { |
| 1688 |
set_catalog_menu(CATSECT_TOP); |
| 1689 |
redisplay(); |
| 1690 |
} else if (mode_commandmenu == MENU_CATALOG |
| 1691 |
&& ((catsect = get_cat_section()) == CATSECT_EXT_TIME |
| 1692 |
|| catsect == CATSECT_EXT_XFCN |
| 1693 |
|| catsect == CATSECT_EXT_BASE |
| 1694 |
|| catsect == CATSECT_EXT_PRGM |
| 1695 |
|| catsect == CATSECT_EXT_STR |
| 1696 |
|| catsect == CATSECT_EXT_STK)) { |
| 1697 |
set_catalog_menu(CATSECT_EXT_1); |
| 1698 |
redisplay(); |
| 1699 |
} else if (mode_commandmenu == MENU_CATALOG |
| 1700 |
&& ((catsect = get_cat_section()) == CATSECT_EXT_STAT |
| 1701 |
|| catsect == CATSECT_EXT_MISC)) { |
| 1702 |
set_catalog_menu(CATSECT_EXT_2); |
| 1703 |
redisplay(); |
| 1704 |
} else if (mode_commandmenu == MENU_CATALOG |
| 1705 |
&& ((catsect = get_cat_section()) == CATSECT_EXT_0_CMP |
| 1706 |
|| catsect == CATSECT_EXT_X_CMP)) { |
| 1707 |
set_catalog_menu(CATSECT_EXT_PRGM); |
| 1708 |
set_cat_row(3); |
| 1709 |
redisplay(); |
| 1710 |
} else { |
| 1711 |
pending_command = CMD_NULL; |
| 1712 |
finish_command_entry(false); |
| 1713 |
} |
| 1714 |
return; |
| 1715 |
} |
| 1716 |
incomplete_length--; |
| 1717 |
if (incomplete_length == 0) { |
| 1718 |
if (incomplete_ind |
| 1719 |
&& mode_commandmenu >= MENU_ALPHA1 |
| 1720 |
&& mode_commandmenu <= MENU_ALPHA_MISC2) |
| 1721 |
goto out_of_alpha; |
| 1722 |
if (incomplete_command == CMD_GTODOT) { |
| 1723 |
incomplete_argtype = ARG_OTHER; |
| 1724 |
incomplete_maxdigits = 4; |
| 1725 |
incomplete_alpha = false; |
| 1726 |
set_menu(MENULEVEL_COMMAND, MENU_IND); |
| 1727 |
redisplay(); |
| 1728 |
return; |
| 1729 |
} else if (incomplete_argtype == ARG_NAMED) { |
| 1730 |
if (incomplete_command == CMD_ASSIGNa) |
| 1731 |
set_catalog_menu(CATSECT_TOP); |
| 1732 |
else |
| 1733 |
set_catalog_menu(CATSECT_VARS_ONLY); |
| 1734 |
if (incomplete_ind) |
| 1735 |
goto out_of_alpha; |
| 1736 |
} else if (incomplete_argtype == ARG_RVAR) { |
| 1737 |
if (vars_exist(CATSECT_REAL)) |
| 1738 |
set_catalog_menu(CATSECT_REAL_ONLY); |
| 1739 |
} else if (incomplete_argtype == ARG_MAT) { |
| 1740 |
if (vars_exist(CATSECT_MAT_LIST)) |
| 1741 |
set_catalog_menu(CATSECT_MAT_LIST_ONLY); |
| 1742 |
} else if (incomplete_argtype == ARG_M_STK) { |
| 1743 |
if (vars_exist(CATSECT_MAT)) |
| 1744 |
set_catalog_menu(CATSECT_MAT_ONLY); |
| 1745 |
} else if (incomplete_argtype == ARG_L_STK) { |
| 1746 |
if (vars_exist(CATSECT_LIST)) |
| 1747 |
set_catalog_menu(CATSECT_LIST_ONLY); |
| 1748 |
} else if (incomplete_argtype == ARG_PRGM) |
| 1749 |
set_catalog_menu(CATSECT_PGM_ONLY); |
| 1750 |
else if (incomplete_argtype == ARG_XSTR) { |
| 1751 |
/* Stay in ALPHA mode */ |
| 1752 |
} else { |
| 1753 |
out_of_alpha: |
| 1754 |
if (incomplete_ind |
| 1755 |
|| incomplete_argtype != ARG_RVAR) |
| 1756 |
incomplete_alpha = false; |
| 1757 |
if (incomplete_ind) |
| 1758 |
set_catalog_menu(CATSECT_REAL_ONLY); |
| 1759 |
else if (incomplete_argtype == ARG_VAR) |
| 1760 |
if (mode_appmenu == MENU_VARMENU) |
| 1761 |
set_menu(MENULEVEL_COMMAND, MENU_VARMENU); |
| 1762 |
else if (mode_appmenu == MENU_INTEG_PARAMS) |
| 1763 |
set_menu(MENULEVEL_COMMAND, MENU_INTEG_PARAMS); |
| 1764 |
else |
| 1765 |
set_catalog_menu(CATSECT_VARS_ONLY); |
| 1766 |
else if (incomplete_argtype == ARG_REAL) |
| 1767 |
if (mode_appmenu == MENU_VARMENU) |
| 1768 |
set_menu(MENULEVEL_COMMAND, MENU_VARMENU); |
| 1769 |
else if (mode_appmenu == MENU_INTEG_PARAMS) |
| 1770 |
set_menu(MENULEVEL_COMMAND, MENU_INTEG_PARAMS); |
| 1771 |
else |
| 1772 |
set_catalog_menu(CATSECT_REAL_ONLY); |
| 1773 |
else if (incomplete_argtype == ARG_LBL) |
| 1774 |
set_catalog_menu(CATSECT_PGM_ONLY); |
| 1775 |
else if (incomplete_command == CMD_GTODOT) |
| 1776 |
set_menu(MENULEVEL_COMMAND, MENU_IND); |
| 1777 |
else if (incomplete_command == CMD_LBL) |
| 1778 |
set_menu(MENULEVEL_COMMAND, MENU_ALPHA1); |
| 1779 |
else |
| 1780 |
set_menu(MENULEVEL_COMMAND, MENU_NONE); |
| 1781 |
} |
| 1782 |
} else if (incomplete_alpha && core_settings.auto_repeat) { |
| 1783 |
repeating = 2; |
| 1784 |
repeating_key = KEY_BSP; |
| 1785 |
repeating_shift = 0; |
| 1786 |
} |
| 1787 |
redisplay(); |
| 1788 |
return; |
| 1789 |
} |
| 1790 |
|
| 1791 |
if (key == KEY_ENTER) { |
| 1792 |
int i; |
| 1793 |
if (incomplete_length == 0) { |
| 1794 |
int catsect; |
| 1795 |
if (mode_commandmenu == MENU_NONE |
| 1796 |
|| (mode_commandmenu == MENU_CATALOG |
| 1797 |
&& ((catsect = get_cat_section()) == CATSECT_TOP |
| 1798 |
|| catsect == CATSECT_EXT_1 |
| 1799 |
|| catsect == CATSECT_EXT_2 |
| 1800 |
|| catsect == CATSECT_PGM_ONLY |
| 1801 |
|| catsect == CATSECT_REAL_ONLY |
| 1802 |
|| catsect == CATSECT_MAT_ONLY |
| 1803 |
|| catsect == CATSECT_LIST_STR_ONLY |
| 1804 |
|| catsect == CATSECT_MAT_LIST_ONLY |
| 1805 |
|| catsect == CATSECT_LIST_ONLY |
| 1806 |
|| catsect == CATSECT_VARS_ONLY))) { |
| 1807 |
set_menu(MENULEVEL_COMMAND, MENU_ALPHA1); |
| 1808 |
redisplay(); |
| 1809 |
return; |
| 1810 |
} else if ((incomplete_command != CMD_ASSIGNa |
| 1811 |
&& incomplete_command != CMD_CLP |
| 1812 |
&& incomplete_command != CMD_PRP |
| 1813 |
&& incomplete_command != CMD_XSTR) |
| 1814 |
|| mode_commandmenu < MENU_ALPHA1 |
| 1815 |
|| mode_commandmenu > MENU_ALPHA_MISC2) { |
| 1816 |
squeak(); |
| 1817 |
return; |
| 1818 |
} |
| 1819 |
/* ASSIGN, CLP, or PRP, XSTR, alpha menu active, zero-length string: |
| 1820 |
* these are the only cases where an empty string is allowed |
| 1821 |
* as an argument. We fall through to the command completion |
| 1822 |
* code below. |
| 1823 |
*/ |
| 1824 |
} |
| 1825 |
|
| 1826 |
pending_command = incomplete_command; |
| 1827 |
|
| 1828 |
if (!incomplete_ind |
| 1829 |
&& (incomplete_command == CMD_GTO |
| 1830 |
|| incomplete_command == CMD_XEQ |
| 1831 |
|| incomplete_command == CMD_LBL |
| 1832 |
|| (incomplete_command >= CMD_KEY1G |
| 1833 |
&& incomplete_command <= CMD_KEY9X)) |
| 1834 |
&& incomplete_length == 1 |
| 1835 |
&& ((incomplete_str[0] >= 'A' |
| 1836 |
&& incomplete_str[0] <= 'J') |
| 1837 |
|| (incomplete_str[0] >= 'a' |
| 1838 |
&& incomplete_str[0] <= 'e'))) { |
| 1839 |
/* Display XEQ "A" briefly before changing to XEQ A */ |
| 1840 |
mode_command_entry = false; |
| 1841 |
pending_command_arg.type = ARGTYPE_STR; |
| 1842 |
pending_command_arg.length = 1; |
| 1843 |
pending_command_arg.val.text[0] = incomplete_str[0]; |
| 1844 |
if (flags.f.prgm_mode) { |
| 1845 |
flags.f.prgm_mode = 0; |
| 1846 |
redisplay(); |
| 1847 |
flags.f.prgm_mode = 1; |
| 1848 |
shell_delay(125); |
| 1849 |
} else |
| 1850 |
redisplay(); |
| 1851 |
pending_command_arg.type = ARGTYPE_LCLBL; |
| 1852 |
pending_command_arg.val.lclbl = incomplete_str[0]; |
| 1853 |
set_menu(MENULEVEL_COMMAND, MENU_NONE); |
| 1854 |
finish_command_entry(false); |
| 1855 |
return; |
| 1856 |
} else { |
| 1857 |
if (incomplete_argtype == ARG_XSTR) { |
| 1858 |
pending_command_arg.type = ARGTYPE_XSTR; |
| 1859 |
pending_command_arg.val.xstr = incomplete_str; |
| 1860 |
} else { |
| 1861 |
pending_command_arg.type = |
| 1862 |
incomplete_ind ? ARGTYPE_IND_STR : ARGTYPE_STR; |
| 1863 |
for (i = 0; i < incomplete_length; i++) |
| 1864 |
pending_command_arg.val.text[i] = incomplete_str[i]; |
| 1865 |
} |
| 1866 |
pending_command_arg.length = incomplete_length; |
| 1867 |
|
| 1868 |
if (!incomplete_ind && incomplete_command == CMD_XEQ) |
| 1869 |
finish_xeq(); |
| 1870 |
else |
| 1871 |
finish_command_entry(true); |
| 1872 |
return; |
| 1873 |
} |
| 1874 |
} |
| 1875 |
|
| 1876 |
squeak(); |
| 1877 |
return; |
| 1878 |
} |
| 1879 |
} |
| 1880 |
|
| 1881 |
void keydown_alpha_mode(int shift, int key) { |
| 1882 |
int menukey; |
| 1883 |
const menu_spec *m = NULL; |
| 1884 |
char c; |
| 1885 |
int command; |
| 1886 |
|
| 1887 |
if (key >= 1024 && key < 2048) { |
| 1888 |
c = key - 1024; |
| 1889 |
goto handle_char; |
| 1890 |
} |
| 1891 |
|
| 1892 |
menukey = find_menu_key(key); |
| 1893 |
if (menukey != -1) { |
| 1894 |
const menu_item_spec *mi; |
| 1895 |
m = menus + mode_alphamenu; |
| 1896 |
mi = m->child + menukey; |
| 1897 |
if (mi->menuid != MENU_NONE) { |
| 1898 |
set_menu(MENULEVEL_ALPHA, mi->menuid); |
| 1899 |
redisplay(); |
| 1900 |
return; |
| 1901 |
} |
| 1902 |
c = mi->title[0]; |
| 1903 |
if (shift && c >= 'A' && c <= 'Z') |
| 1904 |
c += 'a' - 'A'; |
| 1905 |
|
| 1906 |
handle_char: |
| 1907 |
if (flags.f.prgm_mode) { |
| 1908 |
if (!mode_alpha_entry) |
| 1909 |
if (!start_alpha_prgm_line()) { |
| 1910 |
display_error(ERR_PROGRAM_LOCKED); |
| 1911 |
redisplay(); |
| 1912 |
return; |
| 1913 |
} |
| 1914 |
if (entered_string_length < 15) |
| 1915 |
entered_string[entered_string_length++] = c; |
| 1916 |
} else { |
| 1917 |
if (!mode_alpha_entry) { |
| 1918 |
reg_alpha_length = 0; |
| 1919 |
flags.f.alpha_data_input = 1; |
| 1920 |
mode_alpha_entry = true; |
| 1921 |
} |
| 1922 |
append_alpha_char(c); |
| 1923 |
if (reg_alpha_length == 44) |
| 1924 |
squeak(); |
| 1925 |
} |
| 1926 |
if (core_settings.auto_repeat) { |
| 1927 |
repeating = 2; |
| 1928 |
repeating_key = c + 1024; |
| 1929 |
repeating_shift = 0; |
| 1930 |
} |
| 1931 |
|
| 1932 |
if (m != NULL) |
| 1933 |
set_menu(MENULEVEL_ALPHA, m->parent); |
| 1934 |
redisplay(); |
| 1935 |
return; |
| 1936 |
} |
| 1937 |
|
| 1938 |
/* Handle keys that represent characters */ |
| 1939 |
if (!shift) { |
| 1940 |
switch (key) { |
| 1941 |
case KEY_0: c = '0'; break; |
| 1942 |
case KEY_1: c = '1'; break; |
| 1943 |
case KEY_2: c = '2'; break; |
| 1944 |
case KEY_3: c = '3'; break; |
| 1945 |
case KEY_4: c = '4'; break; |
| 1946 |
case KEY_5: c = '5'; break; |
| 1947 |
case KEY_6: c = '6'; break; |
| 1948 |
case KEY_7: c = '7'; break; |
| 1949 |
case KEY_8: c = '8'; break; |
| 1950 |
case KEY_9: c = '9'; break; |
| 1951 |
case KEY_DOT: c = '.'; break; |
| 1952 |
case KEY_E: c = 24; break; |
| 1953 |
case KEY_DIV: c = 0; break; |
| 1954 |
case KEY_MUL: c = 1; break; |
| 1955 |
case KEY_SUB: c = '-'; break; |
| 1956 |
case KEY_ADD: c = '+'; break; |
| 1957 |
default: goto nocharkey2; |
| 1958 |
} |
| 1959 |
} else { |
| 1960 |
switch (key) { |
| 1961 |
case KEY_RCL: c = '%'; break; |
| 1962 |
case KEY_RDN: c = 7; break; |
| 1963 |
default: goto nocharkey2; |
| 1964 |
} |
| 1965 |
} |
| 1966 |
if (flags.f.prgm_mode) { |
| 1967 |
if (!mode_alpha_entry) |
| 1968 |
if (!start_alpha_prgm_line()) { |
| 1969 |
display_error(ERR_PROGRAM_LOCKED); |
| 1970 |
redisplay(); |
| 1971 |
return; |
| 1972 |
} |
| 1973 |
if (entered_string_length < 15) |
| 1974 |
entered_string[entered_string_length++] = c; |
| 1975 |
} else { |
| 1976 |
if (!mode_alpha_entry) { |
| 1977 |
reg_alpha_length = 0; |
| 1978 |
mode_alpha_entry = true; |
| 1979 |
flags.f.alpha_data_input = 1; |
| 1980 |
} |
| 1981 |
append_alpha_char(c); |
| 1982 |
if (reg_alpha_length == 44) |
| 1983 |
squeak(); |
| 1984 |
} |
| 1985 |
if (core_settings.auto_repeat) { |
| 1986 |
repeating = 2; |
| 1987 |
repeating_key = key; |
| 1988 |
repeating_shift = shift; |
| 1989 |
} |
| 1990 |
redisplay(); |
| 1991 |
return; |
| 1992 |
nocharkey2: |
| 1993 |
/* End of handling keys that represent characters */ |
| 1994 |
|
| 1995 |
if (!shift && (key == KEY_UP || key == KEY_DOWN)) { |
| 1996 |
const menu_spec *m = menus + mode_alphamenu; |
| 1997 |
int nextmenu = key == KEY_UP ? m->prev : m->next; |
| 1998 |
if (nextmenu != MENU_NONE) { |
| 1999 |
set_menu(MENULEVEL_ALPHA, nextmenu); |
| 2000 |
redisplay(); |
| 2001 |
} |
| 2002 |
return; |
| 2003 |
} |
| 2004 |
|
| 2005 |
if (key == KEY_EXIT) { |
| 2006 |
const menu_spec *m = menus + mode_alphamenu; |
| 2007 |
set_menu(MENULEVEL_ALPHA, m->parent); |
| 2008 |
if (mode_alphamenu == MENU_NONE) { |
| 2009 |
if (mode_alpha_entry) { |
| 2010 |
if (flags.f.prgm_mode) |
| 2011 |
finish_alpha_prgm_line(); |
| 2012 |
else if ((flags.f.trace_print || flags.f.normal_print) |
| 2013 |
&& flags.f.printer_exists) |
| 2014 |
docmd_pra(NULL); |
| 2015 |
mode_alpha_entry = false; |
| 2016 |
} |
| 2017 |
print_menu_trace("EXIT", 4); |
| 2018 |
pending_command = CMD_CANCELLED; |
| 2019 |
} else |
| 2020 |
redisplay(); |
| 2021 |
return; |
| 2022 |
} |
| 2023 |
|
| 2024 |
if (!shift && key == KEY_BSP) { |
| 2025 |
if (flags.f.prgm_mode) { |
| 2026 |
if (mode_alpha_entry) { |
| 2027 |
if (entered_string_length > 0) { |
| 2028 |
if (core_settings.auto_repeat) { |
| 2029 |
repeating = 2; |
| 2030 |
repeating_key = key; |
| 2031 |
repeating_shift = shift; |
| 2032 |
} |
| 2033 |
entered_string_length--; |
| 2034 |
} else |
| 2035 |
finish_alpha_prgm_line(); |
| 2036 |
} else { |
| 2037 |
int4 line = pc2line(pc); |
| 2038 |
if (line != 0) { |
| 2039 |
if (current_prgm == prgms_count - 1 |
| 2040 |
&& prgms[current_prgm].is_end(pc)) { |
| 2041 |
// .END. |
| 2042 |
pc = line2pc(line - 1); |
| 2043 |
prgm_highlight_row = 0; |
| 2044 |
} else if (prgms[current_prgm].locked) { |
| 2045 |
display_error(ERR_PROGRAM_LOCKED); |
| 2046 |
} else if (current_prgm < prgms_count - 1 |
| 2047 |
&& prgms[current_prgm].is_end(pc) |
| 2048 |
&& prgms[current_prgm + 1].locked) { |
| 2049 |
display_error(ERR_NEXT_PROGRAM_LOCKED); |
| 2050 |
} else { |
| 2051 |
delete_command(pc); |
| 2052 |
pc = line2pc(line - 1); |
| 2053 |
prgm_highlight_row = 0; |
| 2054 |
} |
| 2055 |
} |
| 2056 |
if (mode_alphamenu != MENU_ALPHA1 |
| 2057 |
&& mode_alphamenu != MENU_ALPHA2) |
| 2058 |
set_menu(MENULEVEL_ALPHA, menus[mode_alphamenu].parent); |
| 2059 |
} |
| 2060 |
redisplay(); |
| 2061 |
return; |
| 2062 |
} else { |
| 2063 |
if (mode_alpha_entry && reg_alpha_length > 0) { |
| 2064 |
if (core_settings.auto_repeat) { |
| 2065 |
repeating = 2; |
| 2066 |
repeating_key = key; |
| 2067 |
repeating_shift = shift; |
| 2068 |
} |
| 2069 |
reg_alpha_length--; |
| 2070 |
redisplay(); |
| 2071 |
} else |
| 2072 |
pending_command = CMD_CLA; |
| 2073 |
return; |
| 2074 |
} |
| 2075 |
} |
| 2076 |
|
| 2077 |
if (key == KEY_ENTER) { |
| 2078 |
if (flags.f.prgm_mode) { |
| 2079 |
if (mode_alpha_entry) { |
| 2080 |
finish_alpha_prgm_line(); |
| 2081 |
set_menu(MENULEVEL_ALPHA, MENU_NONE); |
| 2082 |
} else if (shift) { |
| 2083 |
set_menu(MENULEVEL_ALPHA, MENU_NONE); |
| 2084 |
print_menu_trace("ALPHA", 5); |
| 2085 |
} else { |
| 2086 |
if (start_alpha_prgm_line()) { |
| 2087 |
entered_string[0] = 127; |
| 2088 |
entered_string_length = 1; |
| 2089 |
} else |
| 2090 |
display_error(ERR_PROGRAM_LOCKED); |
| 2091 |
} |
| 2092 |
} else { |
| 2093 |
if (shift || mode_alpha_entry) { |
| 2094 |
if (mode_alpha_entry |
| 2095 |
&& (flags.f.trace_print || flags.f.normal_print) |
| 2096 |
&& flags.f.printer_exists) |
| 2097 |
docmd_pra(NULL); |
| 2098 |
mode_alpha_entry = false; |
| 2099 |
set_menu(MENULEVEL_ALPHA, MENU_NONE); |
| 2100 |
} else |
| 2101 |
mode_alpha_entry = true; |
| 2102 |
} |
| 2103 |
redisplay(); |
| 2104 |
return; |
| 2105 |
} |
| 2106 |
|
| 2107 |
command = CMD_CANCELLED; |
| 2108 |
if (!shift) { |
| 2109 |
switch (key) { |
| 2110 |
case KEY_STO: command = CMD_ASTO; break; |
| 2111 |
case KEY_RCL: command = CMD_ARCL; break; |
| 2112 |
case KEY_RUN: command = CMD_RUN; break; |
| 2113 |
default: command = key >= 2048 ? key - 2048 : CMD_NONE; break; |
| 2114 |
} |
| 2115 |
} else { |
| 2116 |
switch (key) { |
| 2117 |
case KEY_CHS: set_plainmenu(MENU_MODES1, "MODES", 5); break; |
| 2118 |
case KEY_E: set_plainmenu(MENU_DISP, "DISP", 4); break; |
| 2119 |
case KEY_BSP: set_plainmenu(MENU_CLEAR1, "CLEAR", 5); break; |
| 2120 |
case KEY_7: set_solve_integ(1); break; |
| 2121 |
case KEY_8: set_solve_integ(0); break; |
| 2122 |
case KEY_9: print_menu_trace("MATRIX", 6); |
| 2123 |
set_menu(MENULEVEL_APP, MENU_MATRIX1); |
| 2124 |
break; |
| 2125 |
case KEY_DIV: print_menu_trace("STAT", 4); |
| 2126 |
set_menu(MENULEVEL_APP, MENU_STAT1); |
| 2127 |
break; |
| 2128 |
case KEY_DOWN: command = CMD_SST; break; |
| 2129 |
case KEY_4: print_menu_trace("BASE", 4); |
| 2130 |
set_menu(MENULEVEL_APP, MENU_BASE1); |
| 2131 |
if (mode_appmenu == MENU_BASE1) { |
| 2132 |
set_appmenu_exitcallback(2); |
| 2133 |
baseapp = 1; |
| 2134 |
} |
| 2135 |
break; |
| 2136 |
case KEY_5: set_plainmenu(MENU_CONVERT1, "CONVERT", 7); break; |
| 2137 |
case KEY_6: set_plainmenu(MENU_FLAGS, "FLAGS", 5); break; |
| 2138 |
case KEY_MUL: set_plainmenu(MENU_PROB, "PROB", 4); break; |
| 2139 |
case KEY_2: set_plainmenu(MENU_NONE, NULL, 0); |
| 2140 |
if (flags.f.prgm_mode) { |
| 2141 |
pending_command = CMD_CUSTOM; |
| 2142 |
return; |
| 2143 |
} else { |
| 2144 |
command = CMD_CUSTOM; |
| 2145 |
break; |
| 2146 |
} |
| 2147 |
case KEY_3: set_plainmenu(MENU_PGM_FCN1, "PGM.FCN", 7); break; |
| 2148 |
case KEY_SUB: set_plainmenu(MENU_PRINT1, "PRINT", 5); break; |
| 2149 |
case KEY_0: set_plainmenu(MENU_TOP_FCN, "TOP.FCN", 7); break; |
| 2150 |
case KEY_DOT: show(); |
| 2151 |
pending_command = CMD_LINGER1; |
| 2152 |
shell_request_timeout3(2000); |
| 2153 |
return; |
| 2154 |
case KEY_ADD: set_plainmenu(MENU_CATALOG, "CATALOG", 7); break; |
| 2155 |
default: command = key >= 2048 ? key - 2048 : CMD_NONE; break; |
| 2156 |
} |
| 2157 |
} |
| 2158 |
|
| 2159 |
if (command == CMD_NONE) { |
| 2160 |
squeak(); |
| 2161 |
return; |
| 2162 |
} |
| 2163 |
if (mode_alpha_entry) { |
| 2164 |
if (flags.f.prgm_mode) |
| 2165 |
finish_alpha_prgm_line(); |
| 2166 |
else if ((flags.f.trace_print || flags.f.normal_print) |
| 2167 |
&& flags.f.printer_exists) |
| 2168 |
docmd_pra(NULL); |
| 2169 |
mode_alpha_entry = false; |
| 2170 |
} |
| 2171 |
|
| 2172 |
if (command == CMD_CANCELLED) { |
| 2173 |
/* plainmenu or appmenu switch */ |
| 2174 |
set_menu(MENULEVEL_ALPHA, MENU_NONE); |
| 2175 |
redisplay(); |
| 2176 |
return; |
| 2177 |
} else |
| 2178 |
do_interactive(command); |
| 2179 |
} |
| 2180 |
|
| 2181 |
void keydown_normal_mode(int shift, int key) { |
| 2182 |
int command; |
| 2183 |
|
| 2184 |
bool invalid; |
| 2185 |
if (is_number_key(shift, key, &invalid)) { |
| 2186 |
if (invalid) |
| 2187 |
return; |
| 2188 |
/* Entering number entry mode */ |
| 2189 |
if (deferred_print) |
| 2190 |
print_command(CMD_NULL, NULL); |
| 2191 |
if (flags.f.prgm_mode && prgms[current_prgm].locked) { |
| 2192 |
display_error(ERR_PROGRAM_LOCKED); |
| 2193 |
redisplay(); |
| 2194 |
return; |
| 2195 |
} |
| 2196 |
cmdline_length = 0; |
| 2197 |
if (get_front_menu() != MENU_NONE) |
| 2198 |
cmdline_row = 0; |
| 2199 |
else |
| 2200 |
cmdline_row = 1; |
| 2201 |
mode_number_entry = !flags.f.prgm_mode && flags.f.big_stack && !flags.f.numeric_data_input ? 2 : 1; |
| 2202 |
if (flags.f.prgm_mode) { |
| 2203 |
if (pc == -1) |
| 2204 |
pc = 0; |
| 2205 |
else if (!prgms[current_prgm].is_end(pc)) |
| 2206 |
pc += get_command_length(current_prgm, pc); |
| 2207 |
prgm_highlight_row = 1; |
| 2208 |
if (cmdline_row == 1) |
| 2209 |
display_prgm_line(0, -1); |
| 2210 |
} else { |
| 2211 |
if (!flags.f.stack_lift_disable) { |
| 2212 |
if (flags.f.big_stack) { |
| 2213 |
if (!ensure_stack_capacity(1)) { |
| 2214 |
display_error(ERR_INSUFFICIENT_MEMORY); |
| 2215 |
return; |
| 2216 |
} |
| 2217 |
sp++; |
| 2218 |
} else { |
| 2219 |
free_vartype(stack[REG_T]); |
| 2220 |
memmove(stack, stack + 1, 3 * sizeof(vartype *)); |
| 2221 |
} |
| 2222 |
stack[sp] = new_real(0); |
| 2223 |
} else |
| 2224 |
flags.f.stack_lift_disable = 0; |
| 2225 |
flags.f.numeric_data_input = 1; |
| 2226 |
mode_varmenu = false; |
| 2227 |
if (cmdline_row == 1) |
| 2228 |
display_y(0); |
| 2229 |
else |
| 2230 |
/* Force repaint of menu; it could be hidden due to a recent |
| 2231 |
* two-line AVIEW command */ |
| 2232 |
redisplay(); |
| 2233 |
} |
| 2234 |
keydown_number_entry(shift, key); |
| 2235 |
return; |
| 2236 |
} |
| 2237 |
|
| 2238 |
if (flags.f.prgm_mode && !shift && key == KEY_BSP) { |
| 2239 |
int4 line = pc2line(pc); |
| 2240 |
if (line == 0) |
| 2241 |
return; |
| 2242 |
if (current_prgm == prgms_count - 1 |
| 2243 |
&& prgms[current_prgm].is_end(pc)) { |
| 2244 |
// .END. |
| 2245 |
pc = line2pc(line - 1); |
| 2246 |
prgm_highlight_row = 0; |
| 2247 |
} else if (prgms[current_prgm].locked) { |
| 2248 |
display_error(ERR_PROGRAM_LOCKED); |
| 2249 |
} else if (current_prgm < prgms_count - 1 |
| 2250 |
&& prgms[current_prgm].is_end(pc) |
| 2251 |
&& prgms[current_prgm + 1].locked) { |
| 2252 |
display_error(ERR_NEXT_PROGRAM_LOCKED); |
| 2253 |
} else { |
| 2254 |
delete_command(pc); |
| 2255 |
pc = line2pc(line - 1); |
| 2256 |
prgm_highlight_row = 0; |
| 2257 |
} |
| 2258 |
redisplay(); |
| 2259 |
return; |
| 2260 |
} |
| 2261 |
|
| 2262 |
if ((mode_appmenu != MENU_NONE |
| 2263 |
|| mode_plainmenu != MENU_NONE |
| 2264 |
|| mode_transientmenu != MENU_NONE) |
| 2265 |
&& mode_alphamenu == MENU_NONE |
| 2266 |
&& mode_commandmenu == MENU_NONE) { |
| 2267 |
int menukey = find_menu_key(key); |
| 2268 |
int menu, level; |
| 2269 |
if (mode_transientmenu != MENU_NONE) { |
| 2270 |
menu = mode_transientmenu; |
| 2271 |
level = MENULEVEL_TRANSIENT; |
| 2272 |
} else if (mode_plainmenu != MENU_NONE) { |
| 2273 |
menu = mode_plainmenu; |
| 2274 |
level = MENULEVEL_PLAIN; |
| 2275 |
} else { |
| 2276 |
menu = mode_appmenu; |
| 2277 |
level = MENULEVEL_APP; |
| 2278 |
} |
| 2279 |
|
| 2280 |
if (menu == MENU_PROGRAMMABLE) { |
| 2281 |
int keynum; |
| 2282 |
if (menukey != -1) |
| 2283 |
keynum = menukey + 1; |
| 2284 |
else if (!shift) { |
| 2285 |
switch (key) { |
| 2286 |
case KEY_UP: keynum = 7; break; |
| 2287 |
case KEY_DOWN: keynum = 8; break; |
| 2288 |
case KEY_EXIT: keynum = 9; break; |
| 2289 |
default: goto notprogmenu; |
| 2290 |
} |
| 2291 |
} else |
| 2292 |
goto notprogmenu; |
| 2293 |
do_prgm_menu_key(keynum); |
| 2294 |
return; |
| 2295 |
notprogmenu:; |
| 2296 |
} |
| 2297 |
|
| 2298 |
if (menu == MENU_VARMENU) { |
| 2299 |
if (menukey != -1) { |
| 2300 |
if (varmenu_labellength[menukey] == 0) { |
| 2301 |
pending_command = CMD_NULL; |
| 2302 |
} else if (shift && !flags.f.prgm_mode) { |
| 2303 |
view(varmenu_labeltext[menukey], |
| 2304 |
varmenu_labellength[menukey]); |
| 2305 |
} else { |
| 2306 |
int i; |
| 2307 |
pending_command_arg.type = ARGTYPE_STR; |
| 2308 |
pending_command_arg.length = |
| 2309 |
varmenu_labellength[menukey]; |
| 2310 |
for (i = 0; i < pending_command_arg.length; i++) |
| 2311 |
pending_command_arg.val.text[i] = |
| 2312 |
varmenu_labeltext[menukey][i]; |
| 2313 |
if (flags.f.prgm_mode) { |
| 2314 |
pending_command = shift ? CMD_VIEW : CMD_STO; |
| 2315 |
store_command_after(&pc, pending_command, |
| 2316 |
&pending_command_arg, NULL); |
| 2317 |
prgm_highlight_row = 1; |
| 2318 |
pending_command = CMD_NONE; |
| 2319 |
redisplay(); |
| 2320 |
} else { |
| 2321 |
switch (varmenu_role) { |
| 2322 |
case 0: /* Plain ol' VARMENU */ |
| 2323 |
case 3: /* VARMNU1 */ |
| 2324 |
pending_command = |
| 2325 |
mode_varmenu ? CMD_VMEXEC : CMD_VMSTO; |
| 2326 |
break; |
| 2327 |
case 1: /* Solver */ |
| 2328 |
pending_command = |
| 2329 |
mode_varmenu ? CMD_VMSOLVE : CMD_VMSTO2; |
| 2330 |
break; |
| 2331 |
case 2: /* Integrator */ |
| 2332 |
if (mode_varmenu) { |
| 2333 |
if ((flags.f.trace_print || flags.f.normal_print) && flags.f.printer_exists) { |
| 2334 |
char buf[9]; |
| 2335 |
int ptr = 0; |
| 2336 |
char2buf(buf, 9, &ptr, '"'); |
| 2337 |
string2buf(buf, 9, &ptr, varmenu_labeltext[menukey], |
| 2338 |
varmenu_labellength[menukey]); |
| 2339 |
char2buf(buf, 9, &ptr, '"'); |
| 2340 |
print_right(NULL, 0, buf, ptr); |
| 2341 |
} |
| 2342 |
set_integ_var(varmenu_labeltext[menukey], |
| 2343 |
varmenu_labellength[menukey]); |
| 2344 |
set_menu(MENULEVEL_APP, MENU_INTEG_PARAMS); |
| 2345 |
set_appmenu_exitcallback(5); |
| 2346 |
redisplay(); |
| 2347 |
return; |
| 2348 |
} else |
| 2349 |
pending_command = CMD_VMSTO; |
| 2350 |
} |
| 2351 |
} |
| 2352 |
} |
| 2353 |
return; |
| 2354 |
} |
| 2355 |
if (!shift && key == KEY_UP) { |
| 2356 |
if (varmenu_rows > 1) { |
| 2357 |
if (--varmenu_row < 0) |
| 2358 |
varmenu_row = varmenu_rows - 1; |
| 2359 |
pending_command = CMD_CANCELLED; |
| 2360 |
} |
| 2361 |
return; |
| 2362 |
} |
| 2363 |
if (!shift && key == KEY_DOWN) { |
| 2364 |
if (varmenu_rows > 1) { |
| 2365 |
if (++varmenu_row >= varmenu_rows) |
| 2366 |
varmenu_row = 0; |
| 2367 |
pending_command = CMD_CANCELLED; |
| 2368 |
} |
| 2369 |
return; |
| 2370 |
} |
| 2371 |
if (key == KEY_EXIT) { |
| 2372 |
set_menu(MENULEVEL_APP, MENU_NONE); |
| 2373 |
if (varmenu_role == 3) { |
| 2374 |
pending_command = CMD_VMEXEC; |
| 2375 |
pending_command_arg.type = ARGTYPE_STR; |
| 2376 |
pending_command_arg.length = 0; |
| 2377 |
} else { |
| 2378 |
print_menu_trace("EXIT", 4); |
| 2379 |
pending_command = CMD_CANCELLED; |
| 2380 |
} |
| 2381 |
return; |
| 2382 |
} |
| 2383 |
} |
| 2384 |
|
| 2385 |
if (menukey != -1) { |
| 2386 |
if (menu == MENU_CUSTOM1 |
| 2387 |
|| menu == MENU_CUSTOM2 |
| 2388 |
|| menu == MENU_CUSTOM3) { |
| 2389 |
if (flags.f.local_label) { |
| 2390 |
if (menukey == 5) { |
| 2391 |
int cmd = shift ? CMD_GTO : CMD_XEQ; |
| 2392 |
do_interactive(cmd); |
| 2393 |
return; |
| 2394 |
} else { |
| 2395 |
pending_command = CMD_XEQ; |
| 2396 |
pending_command_arg.type = ARGTYPE_LCLBL; |
| 2397 |
if (menu == MENU_CUSTOM1) |
| 2398 |
pending_command_arg.val.lclbl = |
| 2399 |
shift ? 'a' + menukey |
| 2400 |
: 'A' + menukey; |
| 2401 |
else |
| 2402 |
pending_command_arg.val.lclbl = 'F' + menukey; |
| 2403 |
if (flags.f.prgm_mode) { |
| 2404 |
store_command_after(&pc, pending_command, |
| 2405 |
&pending_command_arg, NULL); |
| 2406 |
prgm_highlight_row = 1; |
| 2407 |
pending_command = CMD_NONE; |
| 2408 |
set_menu(MENULEVEL_COMMAND, MENU_NONE); |
| 2409 |
redisplay(); |
| 2410 |
} |
| 2411 |
return; |
| 2412 |
} |
| 2413 |
} else { |
| 2414 |
int keynum, length; |
| 2415 |
char name[7]; |
| 2416 |
keynum = menukey + 6 * (menu - MENU_CUSTOM1) + 1; |
| 2417 |
get_custom_key(keynum, name, &length); |
| 2418 |
if (length == 0) |
| 2419 |
squeak(); |
| 2420 |
else { |
| 2421 |
int dummyprgm; |
| 2422 |
int4 dummypc; |
| 2423 |
int i; |
| 2424 |
pending_command_arg.type = ARGTYPE_STR; |
| 2425 |
pending_command_arg.length = length; |
| 2426 |
for (i = 0; i < length; i++) |
| 2427 |
pending_command_arg.val.text[i] = name[i]; |
| 2428 |
if (find_global_label(&pending_command_arg, |
| 2429 |
&dummyprgm, &dummypc)) |
| 2430 |
pending_command = CMD_XEQ; |
| 2431 |
else if (lookup_var(name, length) != -1) |
| 2432 |
pending_command = CMD_RCL; |
| 2433 |
else { |
| 2434 |
int cmd = find_builtin(name, length); |
| 2435 |
if (cmd == -1) |
| 2436 |
pending_command = CMD_XEQ; |
| 2437 |
else if (cmd == CMD_CLALLa) { |
| 2438 |
mode_clall = true; |
| 2439 |
set_menu(MENULEVEL_ALPHA, MENU_NONE); |
| 2440 |
pending_command = CMD_NONE; |
| 2441 |
redisplay(); |
| 2442 |
return; |
| 2443 |
} else if (cmd == CMD_CLV || cmd == CMD_PRV || cmd == CMD_LCLV) { |
| 2444 |
if (!flags.f.prgm_mode && vars_count == 0) { |
| 2445 |
display_error(ERR_NO_VARIABLES); |
| 2446 |
pending_command = CMD_NONE; |
| 2447 |
redisplay(); |
| 2448 |
return; |
| 2449 |
} |
| 2450 |
pending_command = CMD_NONE; |
| 2451 |
do_interactive(cmd); |
| 2452 |
return; |
| 2453 |
} else if ((cmd == CMD_SST || cmd == CMD_SST_UP || cmd == CMD_SST_RT) |
| 2454 |
&& flags.f.prgm_mode) { |
| 2455 |
sst(); |
| 2456 |
pending_command = CMD_NONE; |
| 2457 |
redisplay(); |
| 2458 |
repeating = 1; |
| 2459 |
repeating_shift = 1; |
| 2460 |
repeating_key = KEY_DOWN; |
| 2461 |
return; |
| 2462 |
} else if (cmd == CMD_BST) { |
| 2463 |
bst(); |
| 2464 |
if (!flags.f.prgm_mode) { |
| 2465 |
flags.f.prgm_mode = 1; |
| 2466 |
redisplay(); |
| 2467 |
flags.f.prgm_mode = 0; |
| 2468 |
pending_command = CMD_CANCELLED; |
| 2469 |
} else { |
| 2470 |
redisplay(); |
| 2471 |
pending_command = CMD_NONE; |
| 2472 |
} |
| 2473 |
repeating = 1; |
| 2474 |
repeating_shift = 1; |
| 2475 |
repeating_key = KEY_UP; |
| 2476 |
return; |
| 2477 |
} else if (cmd_array[cmd].argtype == ARG_NONE) { |
| 2478 |
pending_command = cmd; |
| 2479 |
pending_command_arg.type = ARGTYPE_NONE; |
| 2480 |
} else { |
| 2481 |
pending_command = CMD_NONE; |
| 2482 |
do_interactive(cmd); |
| 2483 |
return; |
| 2484 |
} |
| 2485 |
} |
| 2486 |
goto send_it_off; |
| 2487 |
} |
| 2488 |
return; |
| 2489 |
} |
| 2490 |
} else if (menu == MENU_CATALOG) { |
| 2491 |
int catsect; |
| 2492 |
catsect = get_cat_section(); |
| 2493 |
if (catsect == CATSECT_TOP) { |
| 2494 |
switch (menukey) { |
| 2495 |
case 0: |
| 2496 |
print_menu_trace("FCN", 3); |
| 2497 |
set_cat_section(CATSECT_FCN); |
| 2498 |
move_cat_row(0); |
| 2499 |
break; |
| 2500 |
case 1: |
| 2501 |
print_menu_trace("PGM", 3); |
| 2502 |
set_cat_section(CATSECT_PGM); |
| 2503 |
move_cat_row(0); |
| 2504 |
break; |
| 2505 |
case 2: |
| 2506 |
print_menu_trace("REAL", 4); |
| 2507 |
if (vars_exist(CATSECT_REAL)) { |
| 2508 |
set_cat_section(CATSECT_REAL); |
| 2509 |
move_cat_row(0); |
| 2510 |
} else { |
| 2511 |
display_error(ERR_NO_REAL_VARIABLES); |
| 2512 |
flush_display(); |
| 2513 |
return; |
| 2514 |
} |
| 2515 |
break; |
| 2516 |
case 3: |
| 2517 |
print_menu_trace("CPX", 3); |
| 2518 |
if (vars_exist(CATSECT_CPX)) { |
| 2519 |
set_cat_section(CATSECT_CPX); |
| 2520 |
move_cat_row(0); |
| 2521 |
} else { |
| 2522 |
display_error(ERR_NO_COMPLEX_VARIABLES); |
| 2523 |
flush_display(); |
| 2524 |
return; |
| 2525 |
} |
| 2526 |
break; |
| 2527 |
case 4: |
| 2528 |
print_menu_trace("MAT", 3); |
| 2529 |
if (vars_exist(CATSECT_MAT)) { |
| 2530 |
set_cat_section(CATSECT_MAT); |
| 2531 |
move_cat_row(0); |
| 2532 |
} else { |
| 2533 |
display_error(ERR_NO_MATRIX_VARIABLES); |
| 2534 |
flush_display(); |
| 2535 |
return; |
| 2536 |
} |
| 2537 |
break; |
| 2538 |
case 5: |
| 2539 |
display_mem(); |
| 2540 |
pending_command = CMD_LINGER1; |
| 2541 |
shell_request_timeout3(2000); |
| 2542 |
return; |
| 2543 |
} |
| 2544 |
redisplay(); |
| 2545 |
return; |
| 2546 |
} else if (catsect == CATSECT_EXT_1) { |
| 2547 |
switch (menukey) { |
| 2548 |
case 0: |
| 2549 |
print_menu_trace("TIME", 4); |
| 2550 |
set_cat_section(CATSECT_EXT_TIME); |
| 2551 |
break; |
| 2552 |
case 1: |
| 2553 |
print_menu_trace("XFCN", 4); |
| 2554 |
set_cat_section(CATSECT_EXT_XFCN); |
| 2555 |
break; |
| 2556 |
case 2: |
| 2557 |
print_menu_trace("BASE", 4); |
| 2558 |
set_cat_section(CATSECT_EXT_BASE); |
| 2559 |
break; |
| 2560 |
case 3: |
| 2561 |
print_menu_trace("PRGM", 4); |
| 2562 |
set_cat_section(CATSECT_EXT_PRGM); |
| 2563 |
break; |
| 2564 |
case 4: |
| 2565 |
print_menu_trace("STR", 3); |
| 2566 |
set_cat_section(CATSECT_EXT_STR); |
| 2567 |
break; |
| 2568 |
case 5: |
| 2569 |
print_menu_trace("STK", 3); |
| 2570 |
set_cat_section(CATSECT_EXT_STK); |
| 2571 |
break; |
| 2572 |
} |
| 2573 |
move_cat_row(0); |
| 2574 |
redisplay(); |
| 2575 |
return; |
| 2576 |
} else if (catsect == CATSECT_EXT_2) { |
| 2577 |
switch (menukey) { |
| 2578 |
case 0: |
| 2579 |
print_menu_trace("STAT", 4); |
| 2580 |
set_cat_section(CATSECT_EXT_STAT); |
| 2581 |
break; |
| 2582 |
case 1: |
| 2583 |
print_menu_trace("MISC", 4); |
| 2584 |
set_cat_section(CATSECT_EXT_MISC); |
| 2585 |
break; |
| 2586 |
default: |
| 2587 |
squeak(); |
| 2588 |
return; |
| 2589 |
} |
| 2590 |
move_cat_row(0); |
| 2591 |
redisplay(); |
| 2592 |
return; |
| 2593 |
} else if (catsect == CATSECT_PGM |
| 2594 |
|| catsect == CATSECT_PGM_ONLY) { |
| 2595 |
int labelindex = get_cat_item(menukey); |
| 2596 |
if (labelindex == -1) { |
| 2597 |
pending_command = CMD_NULL; |
| 2598 |
return; |
| 2599 |
} |
| 2600 |
if (flags.f.prgm_mode |
| 2601 |
&& labels[labelindex].length == 0) { |
| 2602 |
display_error(ERR_RESTRICTED_OPERATION); |
| 2603 |
flush_display(); |
| 2604 |
pending_command = CMD_NONE; |
| 2605 |
return; |
| 2606 |
} |
| 2607 |
pending_command = CMD_XEQ; |
| 2608 |
pending_command_arg.type = ARGTYPE_LBLINDEX; |
| 2609 |
pending_command_arg.val.num = labelindex; |
| 2610 |
xeq_invisible = 1; |
| 2611 |
if (!flags.f.prgm_mode |
| 2612 |
&& (level == MENULEVEL_TRANSIENT |
| 2613 |
|| !mode_plainmenu_sticky)) { |
| 2614 |
if (level == MENULEVEL_PLAIN) { |
| 2615 |
int row = get_cat_row(); |
| 2616 |
set_menu(MENULEVEL_PLAIN, MENU_NONE); |
| 2617 |
set_menu(MENULEVEL_TRANSIENT, MENU_CATALOG); |
| 2618 |
set_cat_section(catsect); |
| 2619 |
set_cat_row(row); |
| 2620 |
} |
| 2621 |
remove_program_catalog = 1; |
| 2622 |
} |
| 2623 |
} else if (catsect == CATSECT_PGM_SOLVE |
| 2624 |
|| catsect == CATSECT_PGM_INTEG |
| 2625 |
|| catsect == CATSECT_PGM_MENU) { |
| 2626 |
int labelindex = get_cat_item(menukey); |
| 2627 |
int i; |
| 2628 |
if (labelindex == -1) { |
| 2629 |
pending_command = CMD_NULL; |
| 2630 |
return; |
| 2631 |
} |
| 2632 |
if (catsect == CATSECT_PGM_SOLVE) |
| 2633 |
pending_command = flags.f.prgm_mode ? CMD_PGMSLV |
| 2634 |
: CMD_PGMSLVi; |
| 2635 |
else if (catsect == CATSECT_PGM_INTEG) |
| 2636 |
pending_command = flags.f.prgm_mode ? CMD_PGMINT |
| 2637 |
: CMD_PGMINTi; |
| 2638 |
else |
| 2639 |
/* PGMMENU */ |
| 2640 |
pending_command = CMD_PMEXEC; |
| 2641 |
pending_command_arg.type = ARGTYPE_STR; |
| 2642 |
pending_command_arg.length = labels[labelindex].length; |
| 2643 |
for (i = 0; i < pending_command_arg.length; i++) |
| 2644 |
pending_command_arg.val.text[i] = |
| 2645 |
labels[labelindex].name[i]; |
| 2646 |
} else if (catsect == CATSECT_FCN |
| 2647 |
|| catsect >= CATSECT_EXT_TIME && catsect <= CATSECT_EXT_X_CMP) { |
| 2648 |
int cmd = get_cat_item(menukey); |
| 2649 |
if (cmd == CMD_NULL) { |
| 2650 |
if (flags.f.prgm_mode) { |
| 2651 |
pending_command = CMD_NULL; |
| 2652 |
return; |
| 2653 |
} |
| 2654 |
} else if (cmd < 0) { |
| 2655 |
print_menu_trace(cmd == -2 ? "0?" : "X?", 2); |
| 2656 |
set_cat_section(cmd == -2 ? CATSECT_EXT_0_CMP : CATSECT_EXT_X_CMP); |
| 2657 |
move_cat_row(0); |
| 2658 |
redisplay(); |
| 2659 |
pending_command = CMD_NULL; |
| 2660 |
return; |
| 2661 |
} |
| 2662 |
if (level == MENULEVEL_TRANSIENT |
| 2663 |
|| !mode_plainmenu_sticky) |
| 2664 |
set_menu(level, MENU_NONE); |
| 2665 |
do_interactive(cmd); |
| 2666 |
return; |
| 2667 |
} else { |
| 2668 |
int varindex = get_cat_item(menukey); |
| 2669 |
int i; |
| 2670 |
if (varindex == -1) { |
| 2671 |
pending_command = CMD_NULL; |
| 2672 |
return; |
| 2673 |
} |
| 2674 |
pending_command = CMD_RCL; |
| 2675 |
pending_command_arg.type = ARGTYPE_STR; |
| 2676 |
pending_command_arg.length = vars[varindex].length; |
| 2677 |
for (i = 0; i < pending_command_arg.length; i++) |
| 2678 |
pending_command_arg.val.text[i] = |
| 2679 |
vars[varindex].name[i]; |
| 2680 |
if (level == MENULEVEL_TRANSIENT |
| 2681 |
|| !mode_plainmenu_sticky) |
| 2682 |
set_menu(level, MENU_NONE); |
| 2683 |
} |
| 2684 |
send_it_off: |
| 2685 |
if (flags.f.prgm_mode && |
| 2686 |
(cmd_array[pending_command].flags & FLAG_IMMED) == 0) { |
| 2687 |
store_command_after(&pc, pending_command, |
| 2688 |
&pending_command_arg, NULL); |
| 2689 |
if (pending_command == CMD_END) |
| 2690 |
/* current_prgm was already incremented by store_command() */ |
| 2691 |
pc = 0; |
| 2692 |
prgm_highlight_row = 1; |
| 2693 |
pending_command = CMD_NONE; |
| 2694 |
if (level == MENULEVEL_TRANSIENT |
| 2695 |
|| (level == MENULEVEL_PLAIN |
| 2696 |
&& !mode_plainmenu_sticky)) |
| 2697 |
set_menu(level, MENU_NONE); |
| 2698 |
redisplay(); |
| 2699 |
} |
| 2700 |
return; |
| 2701 |
} else if (menu == MENU_INTEG_PARAMS) { |
| 2702 |
if (menukey <= 2) { |
| 2703 |
const char *name; |
| 2704 |
int length; |
| 2705 |
switch (menukey) { |
| 2706 |
case 0: name = "LLIM"; length = 4; break; |
| 2707 |
case 1: name = "ULIM"; length = 4; break; |
| 2708 |
case 2: name = "ACC"; length = 3; break; |
| 2709 |
} |
| 2710 |
if (shift && !flags.f.prgm_mode) |
| 2711 |
view(name, length); |
| 2712 |
else { |
| 2713 |
int i; |
| 2714 |
pending_command_arg.type = ARGTYPE_STR; |
| 2715 |
pending_command_arg.length = length; |
| 2716 |
for (i = 0; i < length; i++) |
| 2717 |
pending_command_arg.val.text[i] = name[i]; |
| 2718 |
if (flags.f.prgm_mode) { |
| 2719 |
pending_command = shift ? CMD_VIEW : CMD_STO; |
| 2720 |
store_command_after(&pc, pending_command, |
| 2721 |
&pending_command_arg, NULL); |
| 2722 |
prgm_highlight_row = 1; |
| 2723 |
pending_command = CMD_NONE; |
| 2724 |
redisplay(); |
| 2725 |
} else { |
| 2726 |
pending_command = CMD_VMSTO; |
| 2727 |
} |
| 2728 |
} |
| 2729 |
} else if (menukey == 5) { |
| 2730 |
int tmp; |
| 2731 |
pending_command_arg.type = ARGTYPE_STR; |
| 2732 |
get_integ_var(pending_command_arg.val.text, &tmp); |
| 2733 |
pending_command_arg.length = tmp; |
| 2734 |
pending_command = CMD_INTEG; |
| 2735 |
} else |
| 2736 |
pending_command = CMD_NULL; |
| 2737 |
return; |
| 2738 |
} else { |
| 2739 |
const menu_item_spec *mi = menus[menu].child + menukey; |
| 2740 |
int cmd_id = mi->menuid; |
| 2741 |
if ((cmd_id & 0x3000) == 0) { |
| 2742 |
set_menu(level, cmd_id); |
| 2743 |
print_menu_trace(mi->title, mi->title_length); |
| 2744 |
redisplay(); |
| 2745 |
return; |
| 2746 |
} |
| 2747 |
cmd_id &= 0xfff; |
| 2748 |
if (shift) { |
| 2749 |
if (menu == MENU_TOP_FCN) { |
| 2750 |
switch (menukey) { |
| 2751 |
case 0: cmd_id = CMD_SIGMASUB; break; |
| 2752 |
case 1: cmd_id = CMD_Y_POW_X; break; |
| 2753 |
case 2: cmd_id = CMD_SQUARE; break; |
| 2754 |
case 3: cmd_id = CMD_10_POW_X; break; |
| 2755 |
case 4: cmd_id = CMD_E_POW_X; break; |
| 2756 |
case 5: cmd_id = CMD_GTO; break; |
| 2757 |
} |
| 2758 |
} else if (menu == MENU_PGM_FCN1) { |
| 2759 |
if (menukey == 5) |
| 2760 |
cmd_id = CMD_GTO; |
| 2761 |
} else if (menu == MENU_STAT1) { |
| 2762 |
if (menukey == 0) |
| 2763 |
cmd_id = CMD_SIGMASUB; |
| 2764 |
} else if (menu == MENU_BASE2) { |
| 2765 |
switch (menukey) { |
| 2766 |
case 0: cmd_id = CMD_SLN; break; |
| 2767 |
case 1: cmd_id = CMD_SRN; break; |
| 2768 |
} |
| 2769 |
} else if (menu == MENU_BASE3) { |
| 2770 |
switch (menukey) { |
| 2771 |
case 0: cmd_id = CMD_RJ; break; |
| 2772 |
case 1: cmd_id = CMD_ASRN; break; |
| 2773 |
} |
| 2774 |
} |
| 2775 |
} |
| 2776 |
if (level == MENULEVEL_TRANSIENT |
| 2777 |
|| (level == MENULEVEL_PLAIN && !mode_plainmenu_sticky)) |
| 2778 |
set_menu(level, MENU_NONE); |
| 2779 |
if (cmd_id == CMD_NULL && flags.f.prgm_mode) |
| 2780 |
pending_command = CMD_NULL; |
| 2781 |
else |
| 2782 |
do_interactive(cmd_id); |
| 2783 |
return; |
| 2784 |
} |
| 2785 |
} |
| 2786 |
|
| 2787 |
if (!shift && (key == KEY_UP || key == KEY_DOWN)) { |
| 2788 |
if (menu == MENU_CATALOG) { |
| 2789 |
move_cat_row(key == KEY_UP ? -1 : 1); |
| 2790 |
redisplay(); |
| 2791 |
} else if (flags.f.local_label |
| 2792 |
&& (menu == MENU_CUSTOM1 |
| 2793 |
|| menu == MENU_CUSTOM2 |
| 2794 |
|| menu == MENU_CUSTOM3)) { |
| 2795 |
set_menu(level, menu == MENU_CUSTOM1 |
| 2796 |
? MENU_CUSTOM2 : MENU_CUSTOM1); |
| 2797 |
redisplay(); |
| 2798 |
} else { |
| 2799 |
const menu_spec *m = menus + menu; |
| 2800 |
int nextmenu = key == KEY_UP ? m->prev : m->next; |
| 2801 |
if (nextmenu != MENU_NONE) { |
| 2802 |
set_menu(level, nextmenu); |
| 2803 |
redisplay(); |
| 2804 |
} |
| 2805 |
} |
| 2806 |
return; |
| 2807 |
} |
| 2808 |
|
| 2809 |
if (key == KEY_EXIT) { |
| 2810 |
print_menu_trace("EXIT", 4); |
| 2811 |
if (menu == MENU_CATALOG) { |
| 2812 |
int catsect = get_cat_section(); |
| 2813 |
if (catsect == CATSECT_FCN |
| 2814 |
|| catsect == CATSECT_PGM |
| 2815 |
|| catsect == CATSECT_REAL |
| 2816 |
|| catsect == CATSECT_CPX |
| 2817 |
|| catsect == CATSECT_MAT) |
| 2818 |
set_cat_section(CATSECT_TOP); |
| 2819 |
else if (catsect >= CATSECT_EXT_TIME |
| 2820 |
&& catsect <= CATSECT_EXT_STK) |
| 2821 |
set_cat_section(CATSECT_EXT_1); |
| 2822 |
else if (catsect == CATSECT_EXT_STAT |
| 2823 |
|| catsect == CATSECT_EXT_MISC) |
| 2824 |
set_cat_section(CATSECT_EXT_2); |
| 2825 |
else if (catsect == CATSECT_EXT_0_CMP |
| 2826 |
|| catsect == CATSECT_EXT_X_CMP) { |
| 2827 |
set_cat_section(CATSECT_EXT_PRGM); |
| 2828 |
set_cat_row(3); |
| 2829 |
} else |
| 2830 |
set_menu(level, MENU_NONE); |
| 2831 |
} else if ((menu == MENU_MATRIX_EDIT1 |
| 2832 |
|| menu == MENU_MATRIX_EDIT2) |
| 2833 |
&& matedit_stack_depth > 0) { |
| 2834 |
if (sp != -1) { |
| 2835 |
int err = docmd_stoel(NULL); |
| 2836 |
if (err != ERR_NONE && err != ERR_NONEXISTENT) { |
| 2837 |
// Nonexistent happens with empty lists |
| 2838 |
display_error(err); |
| 2839 |
flush_display(); |
| 2840 |
return; |
| 2841 |
} |
| 2842 |
} |
| 2843 |
matedit_i = matedit_stack[--matedit_stack_depth]; |
| 2844 |
matedit_j = 0; |
| 2845 |
matedit_is_list = true; |
| 2846 |
if (sp != -1) |
| 2847 |
flags.f.stack_lift_disable = true; |
| 2848 |
int err = docmd_rclel(NULL); |
| 2849 |
if (err != ERR_NONE) |
| 2850 |
display_error(err); |
| 2851 |
redisplay(); |
| 2852 |
return; |
| 2853 |
} else { |
| 2854 |
const menu_spec *m = menus + menu; |
| 2855 |
set_menu(level, m->parent); |
| 2856 |
} |
| 2857 |
pending_command = CMD_CANCELLED; |
| 2858 |
return; |
| 2859 |
} |
| 2860 |
} |
| 2861 |
|
| 2862 |
if (shift && key == KEY_ENTER) { |
| 2863 |
if (deferred_print) |
| 2864 |
print_command(CMD_NULL, NULL); |
| 2865 |
mode_alpha_entry = false; |
| 2866 |
set_menu(MENULEVEL_ALPHA, MENU_ALPHA1); |
| 2867 |
print_menu_trace("ALPHA", 5); |
| 2868 |
redisplay(); |
| 2869 |
return; |
| 2870 |
} |
| 2871 |
|
| 2872 |
if (key == KEY_EXIT && flags.f.prgm_mode) { |
| 2873 |
print_menu_trace("EXIT", 4); |
| 2874 |
flags.f.prgm_mode = 0; |
| 2875 |
pending_command = CMD_CANCELLED; |
| 2876 |
return; |
| 2877 |
} |
| 2878 |
|
| 2879 |
if (key == KEY_UP) { |
| 2880 |
/* Either shift == 1, or there is no menu; this |
| 2881 |
* means BST. This requires special care because it's |
| 2882 |
* one of the rare cases of auto-repeat. |
| 2883 |
* TODO. |
| 2884 |
*/ |
| 2885 |
clear_all_rtns(); |
| 2886 |
squeak(); |
| 2887 |
return; |
| 2888 |
} |
| 2889 |
|
| 2890 |
if (!shift) { |
| 2891 |
switch (key) { |
| 2892 |
case KEY_SIGMA: command = CMD_SIGMAADD; break; |
| 2893 |
case KEY_INV: command = CMD_INV; break; |
| 2894 |
case KEY_SQRT: command = CMD_SQRT; break; |
| 2895 |
case KEY_LOG: command = CMD_LOG; break; |
| 2896 |
case KEY_LN: command = CMD_LN; break; |
| 2897 |
case KEY_XEQ: command = CMD_XEQ; break; |
| 2898 |
case KEY_STO: command = CMD_STO; break; |
| 2899 |
case KEY_RCL: command = CMD_RCL; break; |
| 2900 |
case KEY_RDN: command = CMD_RDN; break; |
| 2901 |
case KEY_SIN: command = CMD_SIN; break; |
| 2902 |
case KEY_COS: command = CMD_COS; break; |
| 2903 |
case KEY_TAN: command = CMD_TAN; break; |
| 2904 |
case KEY_ENTER: command = flags.f.big_stack ? CMD_DUP : CMD_ENTER; break; |
| 2905 |
case KEY_SWAP: command = CMD_SWAP; break; |
| 2906 |
case KEY_CHS: command = basekeys() ? CMD_BASECHS : CMD_CHS; break; |
| 2907 |
case KEY_BSP: command = flags.f.big_stack ? CMD_DROP : CMD_CLX; break; |
| 2908 |
case KEY_DIV: command = basekeys() ? CMD_BASEDIV : CMD_DIV; break; |
| 2909 |
case KEY_DOWN: command = CMD_SST; break; |
| 2910 |
case KEY_MUL: command = basekeys() ? CMD_BASEMUL : CMD_MUL; break; |
| 2911 |
case KEY_SUB: command = basekeys() ? CMD_BASESUB : CMD_SUB; break; |
| 2912 |
case KEY_EXIT: |
| 2913 |
print_menu_trace("EXIT", 4); |
| 2914 |
input_length = 0; |
| 2915 |
pending_command = CMD_CANCELLED; |
| 2916 |
return; |
| 2917 |
case KEY_RUN: command = CMD_RUN; break; |
| 2918 |
case KEY_ADD: |
| 2919 |
if (!flags.f.prgm_mode && sp > 0 && (stack[sp - 1]->type == TYPE_LIST || stack[sp - 1]->type == TYPE_STRING)) |
| 2920 |
command = CMD_APPEND; |
| 2921 |
else |
| 2922 |
command = basekeys() ? CMD_BASEADD : CMD_ADD; |
| 2923 |
break; |
| 2924 |
default: command = key >= 2048 ? key - 2048 : CMD_NONE; break; |
| 2925 |
} |
| 2926 |
} else { |
| 2927 |
switch (key) { |
| 2928 |
case KEY_SIGMA: command = CMD_SIGMASUB; break; |
| 2929 |
case KEY_INV: command = CMD_Y_POW_X; break; |
| 2930 |
case KEY_SQRT: command = CMD_SQUARE; break; |
| 2931 |
case KEY_LOG: command = CMD_10_POW_X; break; |
| 2932 |
case KEY_LN: command = CMD_E_POW_X; break; |
| 2933 |
case KEY_XEQ: command = CMD_GTO; break; |
| 2934 |
case KEY_STO: command = CMD_COMPLEX; break; |
| 2935 |
case KEY_RCL: command = CMD_PERCENT; break; |
| 2936 |
case KEY_RDN: command = CMD_PI; break; |
| 2937 |
case KEY_SIN: command = CMD_ASIN; break; |
| 2938 |
case KEY_COS: command = CMD_ACOS; break; |
| 2939 |
case KEY_TAN: command = CMD_ATAN; break; |
| 2940 |
case KEY_SWAP: command = CMD_LASTX; break; |
| 2941 |
case KEY_CHS: set_plainmenu(MENU_MODES1, "MODES", 5); return; |
| 2942 |
case KEY_E: set_plainmenu(MENU_DISP, "DISP", 4); return; |
| 2943 |
case KEY_BSP: set_plainmenu(MENU_CLEAR1, "CLEAR", 5); return; |
| 2944 |
case KEY_7: set_solve_integ(1); return; |
| 2945 |
case KEY_8: set_solve_integ(0); return; |
| 2946 |
case KEY_9: print_menu_trace("MATRIX", 6); |
| 2947 |
set_menu(MENULEVEL_APP, MENU_MATRIX1); |
| 2948 |
redisplay(); |
| 2949 |
return; |
| 2950 |
case KEY_DIV: print_menu_trace("STAT", 4); |
| 2951 |
set_menu(MENULEVEL_APP, MENU_STAT1); |
| 2952 |
redisplay(); |
| 2953 |
return; |
| 2954 |
case KEY_DOWN: command = CMD_SST; break; |
| 2955 |
case KEY_4: print_menu_trace("BASE", 4); |
| 2956 |
set_menu(MENULEVEL_APP, MENU_BASE1); |
| 2957 |
if (mode_appmenu == MENU_BASE1) { |
| 2958 |
set_appmenu_exitcallback(2); |
| 2959 |
baseapp = 1; |
| 2960 |
redisplay(); |
| 2961 |
} |
| 2962 |
return; |
| 2963 |
case KEY_5: set_plainmenu(MENU_CONVERT1, "CONVERT", 7); return; |
| 2964 |
case KEY_6: set_plainmenu(MENU_FLAGS, "FLAGS", 5); return; |
| 2965 |
case KEY_MUL: set_plainmenu(MENU_PROB, "PROB", 4); return; |
| 2966 |
case KEY_1: command = CMD_ASSIGNa; break; |
| 2967 |
case KEY_2: if (flags.f.prgm_mode) { |
| 2968 |
pending_command = CMD_CUSTOM; |
| 2969 |
return; |
| 2970 |
} else { |
| 2971 |
command = CMD_CUSTOM; |
| 2972 |
break; |
| 2973 |
} |
| 2974 |
case KEY_3: set_plainmenu(MENU_PGM_FCN1, "PGM.FCN", 7); return; |
| 2975 |
case KEY_SUB: set_plainmenu(MENU_PRINT1, "PRINT", 5); return; |
| 2976 |
case KEY_DOT: show(); |
| 2977 |
pending_command = CMD_LINGER1; |
| 2978 |
shell_request_timeout3(2000); |
| 2979 |
return; |
| 2980 |
case KEY_0: set_plainmenu(MENU_TOP_FCN, "TOP.FCN", 7); return; |
| 2981 |
case KEY_ADD: set_plainmenu(MENU_CATALOG, "CATALOG", 7); return; |
| 2982 |
default: command = key >= 2048 ? key - 2048 : CMD_NONE; break; |
| 2983 |
} |
| 2984 |
} |
| 2985 |
|
| 2986 |
if (command == CMD_NONE) |
| 2987 |
return; |
| 2988 |
else |
| 2989 |
do_interactive(command); |
| 2990 |
} |