//{{{ void options_menu(void) { int choice; int old_value, new_value; int change_made = 0; setTabStops(options_menu_tabs); UI_Menu_Set_Persist(1); while(1) { #ifdef OPTIONS_SUBMENUS choice = UI_Menu_Pick(options_rect, count_options()+OPTIONS_SUBMENUS, &cb_options_menu); if(choice>=0 && choice<OPTIONS_SUBMENUS) { pick_submenu(choice); change_made = 1; continue; } else { choice -= OPTIONS_SUBMENUS; } #else choice = UI_Menu_Pick(options_rect, count_options(), &cb_options_menu); #endif if(choice<0) break; old_value = get_option(options[choice].key); new_value = (old_value+1) % count_choices(options[choice].choices); set_option(options[choice].key, new_value); change_made = 1; #ifdef IS_CALCULATOR if(options[choice].key == OPTION_GRAYSCALE) { if(get_option(OPTION_GRAYSCALE) == OPTION_GRAY_ON) GrayOnThrow(); else GrayOff(); if(w->level) // Only if game is started full_redraw(); } #endif #ifdef PALMOS if(options[choice].key == OPTION_INVERSE) init_colors(); #endif #ifdef REALCOMPUTER if(options[choice].key == OPTION_COLOR) init_colors(); #endif } UI_Menu_Set_Persist(0); if(change_made) save_options(); }
/* * Print instructions to screen and prompt to continue */ void printinstrs(scrgame *sg) { /* TODO: Factor out the refresh-everything part */ const char *const *instr; clear(); for (instr = instructions; *instr; instr++) { printw("%s", *instr); } refresh(); getch(); full_redraw(sg); }
bool XPlatformWindow::handle_polled_events() { XEvent event; // OS X, spy breaks this: for(int n = XPending(_display); n > 0; --n) { // So use while loop: while ( XPending(_display) > 0 ) { XNextEvent(_display, &event); switch (event.type) { case Expose: if (event.xexpose.count != 0) break; full_redraw(); // force redraw break; case ConfigureNotify: _width = event.xconfigure.width; _height = event.xconfigure.height; adjust_after_resize(); break; case ReparentNotify: handle_reparent_event(event); break; case ClientMessage: if ((event.xclient.message_type = _wmProtocolsAtom) && (event.xclient.data.l[0] = _wmDeleteWindowAtom)) { // user has selected Quit from window's menu close(); return false; } break; default: break; } } return true; }
/* * Initialize the board and all of the windors in a scrgame */ void initall(scrgame *sg, const int type) { initgame(sg->game, type); full_redraw(sg); }
/* * Prompt user for input, handling backspace, return. * q twice at start of line: quit() * ? at start of line: printinstrs() * Otherwise, read up to length characters from sg->scorer_w into inp * Assume than inp always has room for at least '\0' * Recurse until no errors, return pointer to inp. */ char * getinput(scrgame *sg, char *inp, const int length) { int l, ch, i, quitc; quitc = 0; /* Clear the prompt area */ mvwaddstr(sg->score_w, promptrow, promptcol, " |"); wrefresh(sg->score_w); for (l = 0; l < length - 1; l++) { ch = mvwgetch(sg->score_w, promptrow, promptcol + l); if (ch == 12) { /* We were given a ^L */ full_redraw(sg); update_msgbox(sg->msg_w, ""); for (i = 0; i < l; i++) { mvwaddch(sg->score_w, promptrow, promptcol + i, inp[i]); } wrefresh(sg->score_w); l--; continue; } if (ch == '\b' || ch == KEY_BACKSPACE || ch == KEY_DC || ch == 127) { /* We need to retake the current character; l++ will increase * it, so counteract that with an l-- to remove the BACKSPACE. */ l--; if (l >= 0) { /* Erase the input char from the screen */ mvwaddch(sg->score_w, promptrow, promptcol + l, ' '); /* And another l-- so that we overwrite the input char from * inp on the next iteration of this loop. */ l--; } else { /* We're at the start of the line, so there was no input char * to erase */ } wrefresh(sg->score_w); update_msgbox(sg->msg_w, ""); continue; } else if (isalnum(ch)) { if (ch == 'q' && l == 0) { if (quitc) { quit(); } else { quitc = 1; update_msgbox(sg->msg_w, "Enter 'q' again to quit"); mvwaddch(sg->score_w, promptrow, promptcol, ' '); l--; } } else { inp[l] = (char) ch; mvwaddch(sg->score_w, promptrow, promptcol + l, ch); } wrefresh(sg->score_w); } else if (ch == '?' && l == 0) { printinstrs(sg); mvwaddch(sg->score_w, promptrow, promptcol, ' '); l--; } else if (ch == '\n') { inp[l] = '\0'; break; } else { update_msgbox(sg->msg_w, "Unexpected non-ASCII input"); return getinput(sg, inp, length); } } /* l <= length-1 */ inp[l] = '\0'; return inp; }
/* ------------------- */ void init_rsc(void) { OBJECT *form; register int i, j; rsrc_gaddr(ROOT, SONDER_Z, &form); form[LINE3].ob_spec.free_string[1] = 0; form[LINEA].ob_spec.free_string[31] = 0x7F; for (i = LINE3; i <= LINEA; i++) for (j = 1; j < 33; j += 2) form[i].ob_spec.free_string[j] += 0x80; *form[SOND_EDT].ob_spec.tedinfo->te_ptext = 0; rsrc_gaddr(ROOT, SET_FONT, &form); form[FONT_S].ob_state |= SELECTED; rsrc_gaddr(ROOT, EINRUECK, &form); *form[EINR_NUM].ob_spec.tedinfo->te_ptext = 0; rsrc_gaddr(ROOT, FIND_REP, &form); form[SR_CURSR].ob_state |= SELECTED; form[SR_CRDWN].ob_state |= SELECTED; *form[FIND_STR].ob_spec.tedinfo->te_ptext = 0; *form[REPL_STR].ob_spec.tedinfo->te_ptext = 0; rsrc_gaddr(ROOT, DISK_FMT, &form); form[DRIVE_A].ob_state |= SELECTED; form[NORM_FMT].ob_state |= SELECTED; form[ONE_SIDE].ob_state |= SELECTED; rsrc_gaddr(ROOT, PRT_MENU, &form); form[TO_PRINT].ob_state |= SELECTED; form[NO_INHLT].ob_state |= SELECTED; form[NO_INDEX].ob_state |= SELECTED; form[PRT_PICS].ob_state |= SELECTED; form[NO_MAIL].ob_state |= SELECTED; form[PRT_DRFT].ob_state |= SELECTED; form[PRT_TEXT].ob_state |= SELECTED; rsrc_gaddr(ROOT, NOTE_DIA, &form); form[N_LOCK].ob_state |= SELECTED; for (i = N_LINE2; i <= N_LINE7; i++) { form[i].ob_spec.tedinfo->te_ptmplt = form[N_LINE1].ob_spec.tedinfo->te_ptmplt; form[i].ob_spec.tedinfo->te_pvalid = form[N_LINE1].ob_spec.tedinfo->te_pvalid; form[i].ob_spec.tedinfo->te_txtlen = 40; form[i].ob_spec.tedinfo->te_tmplen = 40; } rsrc_gaddr(ROOT, NEW_RULR, &form); *form[TAB_WDTH].ob_spec.tedinfo->te_ptext = 0; rsrc_gaddr(ROOT, TXT_INFO, &form); form[EINZ_SWT].ob_state |= SELECTED; form[PASS_SWT].ob_state |= SELECTED; for (i = TI_LINE1; i <= TI_LINE9; i++) { form[i].ob_spec.tedinfo->te_ptmplt = form[TI_LINE1].ob_spec.tedinfo->te_ptmplt; form[i].ob_spec.tedinfo->te_pvalid = form[TI_LINE1].ob_spec.tedinfo->te_pvalid; form[i].ob_spec.tedinfo->te_tmplen = 40; form[i].ob_spec.tedinfo->te_txtlen = 40; } form[TI_LINEA].ob_spec.tedinfo->te_txtlen = 34; form[TI_BEARE].ob_spec.tedinfo->te_txtlen = 29; rsrc_gaddr(ROOT, KOPFFUSS, &form); for (i = 0; i < 12; i++) { form[kf_anp[i]].ob_spec.tedinfo->te_ptmplt = form[G_LFT_1].ob_spec.tedinfo->te_ptmplt; form[kf_anp[i]].ob_spec.tedinfo->te_pvalid = form[G_LFT_1].ob_spec.tedinfo->te_pvalid; form[kf_anp[i]].ob_spec.tedinfo->te_txtlen = 26; form[kf_anp[i]].ob_spec.tedinfo->te_tmplen = 26; } rsrc_gaddr(ROOT, FLOSKEL, &form); for (i = FLSK_L1; i <= FLSK_L5; i++) { form[i].ob_spec.tedinfo->te_ptmplt = form[FLSK_L1].ob_spec.tedinfo->te_ptmplt; form[i].ob_spec.tedinfo->te_pvalid = form[FLSK_L1].ob_spec.tedinfo->te_pvalid; form[i].ob_spec.tedinfo->te_tmplen = 40; form[i].ob_spec.tedinfo->te_txtlen = 40; } get_work(0); rsrc_gaddr(ROOT, BACKGRND, &back); back[ROOT].ob_x = wx; back[ROOT].ob_y = wy; back[ROOT].ob_width = ww; back[ROOT].ob_height = wh; ww = (ww - 20) / 10; wx += 10; wy = wh - back[F1].ob_height - 20; for (i = 0; i < 40; i += 4) { back[F1 + i].ob_x = wx; back[F1 + i].ob_y = wy; back[F1 + i].ob_width = ww; back[F1_BUT + i].ob_width = ww; back[F1_BUT + i].ob_type = G_BOX; back[F1_BUT].ob_spec.index |= 0xFF0000; back[F1_TXT + i].ob_width = ww; back[F1_TXT + i].ob_spec.tedinfo->te_ptext = f_text[((i < 36) ? i / 4 + 1 : 0)]; wx += ww; } wind_set(0, WF_NEWDESK, back, 0, 0); full_redraw(); }