static void paste_run(void) { int count=0; k_printf("KBD: paste_run running\n"); if (paste_buffer) { /* paste in progress */ while (1) { t_unicode keysym; keysym = paste_buffer[paste_idx]; put_symbol(PRESS, keysym); put_symbol(RELEASE, keysym); count++; if (++paste_idx == paste_len) { /* paste finished */ free(paste_buffer); paste_buffer=NULL; paste_len=paste_idx=0; k_printf("KBD: paste finished\n"); break; } } k_printf("KBD: paste_run() pasted %d chars\n",count); } }
/****************************************************************************** * * S T O R E _ S Y M B O L (char *name, int type, node *n) * * Stores a given node under the given name, with the given symbol type * in the active symbol table using put_symbol(). * ****************************************************************************** */ value store_symbol(char *name, int type, node * n) { if (n == NODENIL) return exception("SYSERR memory exhausted in store_symbol()"); else return (put_symbol(value_symtab(activesymtab(type)), name, type, n)); }
/* * Insert a symbol into the project database. * See the API documentation for detailed information. */ int sn_insert_symbol(int id_type, char *classname, char *identifier, char *filename, int start_lineno, int start_colpos, int end_lineno, int end_colpos, unsigned long attr, char *ret, char *arg_types, char *arg_names, char *comment, int high_start_lineno, int high_start_colpos, int high_end_lineno, int high_end_colpos) { return(put_symbol(id_type, classname, identifier, filename, start_lineno, start_colpos, end_lineno, end_colpos, attr, ret, arg_types, arg_names, comment, high_start_lineno, high_start_colpos, high_end_lineno, high_end_colpos)); }
/* Ensure the symbol with name `name' exists uniquely in the hash table `table'. */ Symbol ensure_symbol_exists(char *name, Package pkg) { Symbol symbol; symbol = get_symbol(name, PACKAGE_HASH_TABLE(pkg)); if (symbol != NULL) return symbol; else { symbol = make_symbol(name, pkg, NULL, NULL, NULL); put_symbol(symbol, PACKAGE_HASH_TABLE(pkg)); return symbol; } }
extern void end_eightva(int stave) { int sign = (wrk.eightva[stave].down ? -1 : 1); int end = (sign < 0 ? STAVE_BOTTOM : STAVE_TOP); int numpos = (sign < 0 ? 0 : -smalldigit_ht); put_symbol (wrk.eightva[stave].x + eightva_fwd, wrk.eightva[stave].ax, stave_y(stave, end) + sign*eightva_yoff + numpos, s_small8); put_line (wrk.eightva[stave].x + eightva_lstart, wrk.eightva[stave].ax, stave_y(stave, end) + sign*eightva_yoff, xpos - eightva_back, axpos, stave_y(stave, end) + sign*eightva_yoff, thin_barline); put_line (xpos - eightva_back, axpos, stave_y(stave, end) + sign*eightva_yoff, xpos - eightva_back, axpos, stave_y(stave, end) + sign*(eightva_yoff-smalldigit_ht), thin_barline); wrk.eightva[stave].exists = FALSE; }
static t_unicode *type_one_key(t_unicode *in) { int esc, keynum; t_unicode ch; t_unicode keysym; static char ctrl[]="JMGHLIK"; stroke_pause = default_stroke_pause; if (!in || !in[0]) return 0; ch=*(in++); switch(ch) { case '\\': { ch=(*in++); if (!ch) return 0; esc = -1; switch(ch) { case 'v': esc++; case 't': esc++; case 'f': esc++; case 'b': esc++; case 'a': esc++; case 'r': esc++; case 'n': esc++; case '^': { /* example: \a == \^G == <Ctrl>G \r == \^M == <Ctrl>M == <ENTER> */ if (esc >= 0) ch = ctrl[esc]; else ch = *(in++); keysym = ch; if (keysym != KEY_VOID) { if (keysym == KEY_M) { put_symbol(PRESS, KEY_RETURN); put_symbol(RELEASE, KEY_RETURN); } else { put_modified_symbol(PRESS, MODIFIER_CTRL, keysym); put_modified_symbol(RELEASE, MODIFIER_CTRL, keysym); } } return in; } case 'A': { /* example: \Az == <Alt>z */ ch = *(in++); keysym = ch; if (keysym != KEY_VOID) { put_modified_symbol(PRESS, MODIFIER_ALT, keysym); put_modified_symbol(RELEASE, MODIFIER_ALT, keysym); } return in; } case 'F': { /* example: \F12; == key F12 \F1; == key F1 */ keynum = GETNUMBER(in); if ((keynum > 0) && (keynum < 12)) { keysym = KEY_F1 + keynum -1; put_symbol(PRESS, keysym); /* key pressed */ put_symbol(RELEASE, keysym); /* key released */ } return in; } case 'p': { /* example: \p100; == pause one second */ keynum = GETNUMBER(in); if ((keynum > 0) && (keynum < 10000)) { stroke_pause = keynum; } return in; } case 'P': { /* example: \P15; == set rate to 100/15 cps */ keynum = GETNUMBER(in); if (keynum > 0) { keynum--; if (keynum > 100) keynum = 100; default_stroke_pause = keynum; } return in; } case 'M': { /* 'M' == as in Move, ('P' would be nicer (Pu for PageUp) but is already used...) example: \Mh == <HOME> \Mu == <PageUp> \Me == <END> \Md == <PageDown> \M8 == <ArrowUp> \M4 == <ArrowLeft> \M6 == <ArrowRight> \M2 == <ArrowDown> */ ch=*(in++); switch(ch) { case 'i': keynum = KEY_INS; break; /* KEY_INS */ case 'h': keynum = KEY_HOME; break; /* KEY_HOME */ case 'u': keynum = KEY_PGUP; break; /* KEY_PGUP */ case 'c': keynum = KEY_DEL; break; /* KEY_DEL */ case 'e': keynum = KEY_END; break; /* KEY_END */ case 'd': keynum = KEY_PGDN; break; /* KEY_PGDN */ case '8': keynum = KEY_UP; break; /* KEY_UP */ case '4': keynum = KEY_LEFT; break; /* KEY_LEFT */ case '6': keynum = KEY_RIGHT; break; /* KEY_RIGHT */ case '2': default: keynum = KEY_DOWN; break; /* KEY_DOWN */ } move_key(PRESS, keynum); move_key(RELEASE, keynum); return in; } default: ; /* fall through */ } } default: { keysym = ch; if (keysym != KEY_VOID) { put_symbol(PRESS, keysym); /* key pressed */ put_symbol(RELEASE, keysym); /* key release */ } return in; } } return in; }
Self & put(Symbol symbol) { put_symbol(symbol); tree << symbol; ++Base::symbol_count; return *this; }
int move(board_t* board, symbol_t symbol, int depth, int alpha, int beta) { int n, i; move_t* max_move; int score = get_score(board, depth, symbol); if(score != 0) { return score; } move_t** moves = get_all_possible_moves(board, symbol, &n); if(depth == 0) { int max_score = -9999; board_t* b; #pragma omp parallel for private(i, score, b) shared(board, alpha, beta, moves, depth, symbol, max_score) schedule(guided, CHUNK_SIZE) for(i = 0; i < n; i++) { b = clone_board(board); put_symbol(b, symbol, moves[i]); score = -move(b, other_symbol(symbol), depth + 1, -beta, -max_score); #pragma omp critical { if(score > max_score) { max_score = score; max_move = moves[i]; } } free(b); } alpha = max_score; } else { for(i = 0; i < n; i++) { put_symbol(board, symbol, moves[i]); score = -move(board, other_symbol(symbol), depth + 1, -beta, -alpha); clear_symbol(board, moves[i]); if(score > alpha) { alpha = score; max_move = moves[i]; } if(alpha >= beta) { if(depth == 0) { printf("%i %i %i\n", i, beta, alpha); } break; } } } if(depth == 0) { put_symbol(board, symbol, max_move); } for(i = 0; i < n; i++) { free(moves[i]); } free(moves); return alpha; }