static void search_mode_key(enum term_key_type type, unsigned int key) { switch (type) { case KEY_NORMAL: switch (key) { case '\r': if (cmdline.buf.buffer[0]) { search_set_regexp(cmdline.buf.buffer); search_next(); history_add(&search_history, cmdline.buf.buffer, search_history_size); } else { search_next(); } cmdline_clear(&cmdline); set_input_mode(INPUT_NORMAL); break; } break; case KEY_META: switch (key) { case 'c': options.case_sensitive_search = (options.case_sensitive_search + 1) % 3; break; case 'r': search_set_direction(current_search_direction() ^ 1); break; } break; case KEY_SPECIAL: break; case KEY_PASTE: break; } }
int search_food(t_player *p) { char *s; my_send(p->server_socket, "voir\n"); s = gnl_parsing(p); if (s) { if (pseudo_clever_move(s, "nourriture", p) == 1) { free(s); my_send(p->server_socket, "prend nourriture\n"); if ((s = gnl_parsing(p)) && my_strcmp(s, "ok\n") == 0) { free(s); if (search_next(p) == 1) return (1); } } } free(s); myopic_move(p); search_food(p); return (1); }
static void cmd_ctrl_n(key_info_t key_info, keys_info_t *keys_info) { stop_completion(); if(input_stat.history_search == HIST_NONE) save_users_input(); input_stat.history_search = HIST_GO; search_next(); }
static void cmd_down(key_info_t key_info, keys_info_t *keys_info) { stop_completion(); if(input_stat.history_search == HIST_NONE) save_users_input(); if(input_stat.history_search != HIST_SEARCH) { input_stat.history_search = HIST_SEARCH; input_stat.hist_search_len = input_stat.len; } search_next(); }
bool G_refSearcher::search(const G_refs &refs) { int i; bool flag; //first check if any given refs are true or if all given refs are false flag = true; for(i = 0; i < int(refs.size()); ++i) { hash_map<G_ref *, bool>::const_iterator it = known_refs.find(refs[i]); if(it != known_refs.end()) { if((*it).second == true) return true; } else flag = false; } if(flag) return false; //now do the recursive search for(i = 0; i < int(refs.size()); ++i) { hash_map<G_ref *, bool>::const_iterator it = known_refs.find(refs[i]); if(it != known_refs.end()) { // if we already know about this ref if((*it).second == true) return true; else continue; } if(is_found(refs[i])) { //if the current object is what we're looking for, we're done. known_refs[refs[i]] = true; return true; } //temporaries have a life at least until the end of the block const G_refs &next = search_next(refs[i]); bool result; if(next.size()) result = search(next); //recursively search else result = false; known_refs[refs[i]] = result; if(result == true) return true; } return false; }
char fcg_function_parameters_set(struct fcg_function *function, struct fcg_parameter **parameters_sorted, size_t parameters_sorted_length) { if(function->parameters_set) return 0; qsort(function->parameter_names, function->parameters_length, sizeof(char*), (int (*)(void const *, void const *))fcg_tools_string_compare_ptr); struct fcg_parameter **parameters = (struct fcg_parameter **)malloc( sizeof(struct fcg_parameter *) * function->parameters_length); size_t j = 0; for(size_t i = 0; i < function->parameters_length; ++i) { char search_next() { while(1) { if(j >= parameters_sorted_length) return 1; if(!strcmp(function->parameter_names[i], parameters_sorted[j]->name)) return 0; j++; } } if(search_next()) { free(parameters); return 1; } else parameters[i] = parameters_sorted[j]; } for(size_t i = 0; i < function->parameters_length; ++i) free(function->parameter_names[i]); free(function->parameters); function->parameters = parameters; function->parameters_set = 1; return 0; }
/******************************************************************** * * * Gestion du menu * * * ********************************************************************/ boolean MenuSelect(int object, int scan, int state, int button) { int index, entree, key; if (object < 0) { /* attend qu'on relache la souris */ NoClick(); if (button < 0) { /* regarde la touche */ key = scantoascii(scan); if (key == 0) key = scan & 0xFF00; /* scan code */ else key = UpperChar(key); for (index = 0; index < NbMenus; index++) for (entree = 0; entree < MenuShortCuts[index].nb_entrees; entree++) if (MenuShortCuts[index].menu[entree].key == key && MenuShortCuts[index].menu[entree].state == state) { if (ob_isstate(Menu, MenuShortCuts[index].menuid, DISABLED) == 0 && ob_isstate(Menu, MenuShortCuts[index].menu[entree].itemid, DISABLED) == 0) { object = MenuShortCuts[index].menu[entree].itemid; index = NbMenus; } break; } } } if (object < 0) return FALSE; /* kein entsprechender Eintrag gefunden */ /* Men�punkte 'Fenster wechseln' und 'Fenster schliežen' werden inklusive der dazugeh”rigen Hotkeys automatisch verwaltet */ switch (object) { /* menu Zorg */ case INFORMATIONS: presentation(); break; /* menu Etat */ case INFORMATION: informations(Drive); break; case REPERTOIRE_LOUPE: if (ManageVFAT) open_directory_vfat(); else open_directory_short(); break; case TEST_STRUCTURE: if (ManageVFAT) structure_test_vfat(Drive); else structure_test_short(Drive); break; case STATISTIQUES: statistiques(Drive); break; case OCCUPATION: occupation(Drive); break; case TRACE_UN_FICHIER: trace_file(); break; case QUITTER: if (Reset) { if (my_alert(1, 2, X_ICN_QUESTION, Messages(MENU_1), Messages(BOOT_32)) == 0) shutdown(TRUE); } else { button = my_alert(2, 3, X_ICN_QUESTION, Messages(MENU_2), Messages(MENU_4)); if (button == 0 || button == 1 && (int)xbios(0x11) % 2) shutdown(FALSE); } break; /* menu Ouvre */ case UNITE_LOGIQUE: open_disk(); break; case OUVRE_DISQUETTE: raw_floppy(FALSE); break; case OUVRE_DISQUE_DUR: raw_hard(FALSE); break; case OUVRE_FICHIER: open_file(); break; case OUVRE_FICHIER_FS: open_file_other_fs(); break; case OUVRE_FICH_TEXTE: voir_fichier(); break; case CREER_FICHIER: creer_fichier(); break; case FERMER: fermer(Thefrontwin -> win -> handle); break; case LIRE_BOOT: lire_boot(); break; case CHARGER_BOOT: charger_boot(); break; case SAUVER_BOOT: sauver_boot(); break; case ECRIRE_BOOT: #ifdef TEST_VERSION /* relache la souris */ NoClick(); /* on attend avant de redessiner */ Event_Timer(0, 0, TRUE); my_alert(1, FAIL, X_ICN_STOP, Messages(MENU_6), NULL); #else ecrire_boot(); #endif break; /* menu Edition */ case SAUVER_SECTEUR: #ifdef TEST_VERSION /* relache la souris */ NoClick(); /* on attend avant de redessiner */ Event_Timer(0, 0, TRUE); my_alert(1, FAIL, X_ICN_STOP, Messages(MENU_6), NULL); #else save_secteur(Thefrontwin, MENU_EDITION); #endif break; case COPIER_SECTEUR: copier_tampon(Thefrontwin); break; case COLLER_SECTEUR: coller_tampon(Thefrontwin); break; case ECHANGER_TAMPON: echanger_tampon(Thefrontwin); break; case RETOUR_INITIAL: load_secteur(Thefrontwin, MENU_EDITION); break; case OUVRIR_TAMPON: ouvrir_tampon(); break; case SAUVER_TAMPON: sauver_tampon(); break; case CHARGER_TB_ASCII: ascii_tampon(); break; case EFFACER_TAMPON: effacer_tampon(); break; /* menu Structure */ case DEFRAGMENTATION: #ifdef TEST_VERSION /* relache la souris */ NoClick(); /* on attend avant de redessiner */ Event_Timer(0, 0, TRUE); my_alert(1, FAIL, X_ICN_STOP, Messages(MENU_6), NULL); #else reconnect(Drive); #endif break; case UNIQUE_LIBRE: #ifdef TEST_VERSION /* relache la souris */ NoClick(); /* on attend avant de redessiner */ Event_Timer(0, 0, TRUE); my_alert(1, FAIL, X_ICN_STOP, Messages(MENU_6), NULL); #else compresse(Drive); #endif break; case RESTO_COMPLETE: #ifdef TEST_VERSION /* relache la souris */ NoClick(); /* on attend avant de redessiner */ Event_Timer(0, 0, TRUE); my_alert(1, FAIL, X_ICN_STOP, Messages(MENU_6), NULL); #else restauration_complete(Drive); #endif break; case VIDE_CLST_LIBRES: nettoie_clusters_libres(Drive); break; case NETTOIE_REPERTOI: #ifdef TEST_VERSION /* relache la souris */ NoClick(); /* on attend avant de redessiner */ Event_Timer(0, 0, TRUE); my_alert(1, FAIL, X_ICN_STOP, Messages(MENU_6), NULL); #else nettoie_repertoire(Drive); #endif break; /* menu Deplacement */ case SECTEUR_SUIVANT: next_secteur(Thefrontwin); break; case SECTEUR_PRECEDEN: previous_secteur(Thefrontwin); break; case BLOC_SUIVANT: next_bloc(Thefrontwin); break; case BLOC_PRECEDENT: previous_bloc(Thefrontwin); break; case MARQUER_POSITION: marquer_position(Thefrontwin); break; case ALLER_MARQUE: goto_marque(Thefrontwin); break; case ALLER_SECTEUR: goto_secteur(Thefrontwin); break; case CHERCHER_CHAINE: search_first(Thefrontwin); break; case CHERCHER_NOUVEAU: search_next(Thefrontwin); break; /* menu Fenˆtres */ case CHOIX_FONTE: choix_fonte(Thefrontwin); break; case CHOIX_COULEURS: couleur(Thefrontwin); break; case TAILLE_IDEALE: taille_ideale(Thefrontwin); break; case ASCENSEURS: ascenseurs(Thefrontwin); break; case CYCLER_FENETRES: cycle_window(); break; case WINDOW_LIST_1: case WINDOW_LIST_2: case WINDOW_LIST_3: case WINDOW_LIST_4: case WINDOW_LIST_5: case WINDOW_LIST_6: case WINDOW_LIST_7: case WINDOW_LIST_8: case WINDOW_LIST_9: case WINDOW_LIST_10: { windowptr thewin; for (thewin = Firstwindow; thewin; thewin = thewin -> next) if (thewin -> menu_entry == object - WINDOW_LIST_1) make_frontwin(thewin); } break; /* menu Options */ case CONFIG_GENERALE: config_generale(); break; case CONFIG_DSK: config_disques(); break; case RACCOURCIS_CLAVI: raccourcis_clavier(); break; case DONNEES_ZORG: from_zorg_inf(TRUE); break; case DONNEES_SYSTEME: from_zorg_inf(FALSE); break; case INVALIDE_CACHE: if (Kbshift(FAIL) & 4) { int i; for (i=0; i<MAX_DEVICES; i++) change_disque(i, FALSE); } else change_disque(Drive, TRUE); break; case UPDATE_SYSTEME: if (Kbshift(FAIL) & 4) { int i; for (i=0; i<MAX_DEVICES; i++) update_systeme(i); } else update_systeme(Drive); break; case VISU_TEXTE: really_voir_fichier(Thefrontwin -> fonction.fichier.nom); break; case VISU_ASCII: secteur_ascii(Thefrontwin); break; case VISU_HEXA: secteur_hexa(Thefrontwin); break; case AFFICHE_DECIMAL: affichage_decimal(Thefrontwin); break; case FICHIER_ASSOCIE: secteur_file(Thefrontwin); break; case CURSEUR_VISIBLE: curseur_on(Thefrontwin); break; case CLIPBOARD_GEM: clipboard_gem(Thefrontwin); break; /* menu Aide */ case TABLE_ASCII: AsciiChar = m_ascii_box(AsciiChar, FALSE); break; case AIDE: aide(); break; case EXECUTER_PROG: lance_prg(); break; case RESET: if (Reset) { Reset = FALSE; menu_icheck(Menu, RESET, 0); } else { int button; button = my_alert(2, 3, X_ICN_QUESTION, Messages(MENU_3), Messages(MENU_5)); if (button == 1) shutdown(TRUE); else if (button == 0) reset(); } break; } return TRUE; } /* MenuSelect */
void update(const Board& board, Disc disc, eval_t error, int beta, int n_sample) { Board next = board; next.move(search_next(board, disc), disc); evaluator_.update(next, (Disc)-disc, error, beta, n_sample); }
void FindReplaceBar::_search_text_entered(const String &p_text) { search_next(); }
void FindReplaceBar::_replace_all() { // line as x so it gets priority in comparison, column as y Point2i orig_cursor(text_edit->cursor_get_line(), text_edit->cursor_get_column()); Point2i prev_match = Point2(-1, -1); bool selection_enabled = text_edit->is_selection_active(); Point2i selection_begin, selection_end; if (selection_enabled) { selection_begin = Point2i(text_edit->get_selection_from_line(), text_edit->get_selection_from_column()); selection_end = Point2i(text_edit->get_selection_to_line(), text_edit->get_selection_to_column()); } int vsval = text_edit->get_v_scroll(); text_edit->cursor_set_line(0); text_edit->cursor_set_column(0); String replace_text = get_replace_text(); int search_text_len = get_search_text().length(); int rc = 0; replace_all_mode = true; text_edit->begin_complex_operation(); while (search_next()) { // replace area Point2i match_from(result_line, result_col); Point2i match_to(result_line, result_col + search_text_len); if (match_from < prev_match) break; // done prev_match = Point2i(result_line, result_col + replace_text.length()); text_edit->select(result_line, result_col, result_line, match_to.y); if (selection_enabled && is_selection_only()) { if (match_from < selection_begin || match_to > selection_end) continue; // replace but adjust selection bounds text_edit->insert_text_at_cursor(replace_text); if (match_to.x == selection_end.x) selection_end.y += replace_text.length() - search_text_len; } else { // just replace text_edit->insert_text_at_cursor(replace_text); } rc++; } text_edit->end_complex_operation(); replace_all_mode = false; // restore editor state (selection, cursor, scroll) text_edit->cursor_set_line(orig_cursor.x); text_edit->cursor_set_column(orig_cursor.y); if (selection_enabled && is_selection_only()) { // reselect text_edit->select(selection_begin.x, selection_begin.y, selection_end.x, selection_end.y); } else { text_edit->deselect(); } text_edit->set_v_scroll(vsval); set_error(vformat(TTR("Replaced %d occurrence(s)."), rc)); }
static gboolean on_treeview_key_press_event (GtkWidget *widget, GdkEventKey *event, gpointer user_data) { GtkTreeView *view = GTK_TREE_VIEW(widget); GtkTreeModel *model = gtk_tree_view_get_model(view); GtkTreeIter iter; GtkTreePath *path; GtkTreeViewColumn *column; gchar *str; gchar *row; gint row_idx, row_max; uint32_t min, max; gint n; GtkNotebook *nb = GTK_NOTEBOOK(notebook); gint page = gtk_notebook_get_current_page(nb); // get min address gtk_tree_model_get_iter_first(model, &iter); gtk_tree_model_get(model, &iter, COL_ADDR, &str, -1); sscanf(str, "%x", &min); // get max address n = gtk_tree_model_iter_n_children(model, NULL); gtk_tree_model_iter_nth_child(model, &iter, NULL, n-1); gtk_tree_model_get(model, &iter, COL_ADDR, &str, -1); sscanf(str, "%x", &max); // retrieve cursor gtk_tree_view_get_cursor(view, &path, &column); if(path == NULL) return FALSE; // get row row_idx = row_max = -1; row = gtk_tree_path_to_string(path); sscanf(row, "%i", &row_idx); g_free(row); row_max = gtk_tree_model_iter_n_children(model, NULL) - 1; //printf("row_idx = %i\n", row_idx); switch(event->keyval) { case GDK_Up: if(row_max == -1) break; if(row_idx > 0) break; refresh_page(page, -0x10); return FALSE; case GDK_Down: if(row_max == -1) break; if(row_idx < row_max) break; refresh_page(page, +0x10); str = g_strdup_printf("%i", row_max); path = gtk_tree_path_new_from_string(str); g_free(str); gtk_tree_view_set_cursor(view, path, NULL, FALSE); return FALSE; case GDK_Page_Up: if(row_max == -1) break; if(row_idx > 0) break; refresh_page(page, -DUMP_SIZE); path = gtk_tree_path_new_from_string("0"); gtk_tree_view_set_cursor(view, path, NULL, FALSE); return FALSE; case GDK_Page_Down: if(row_max == -1) break; if(row_idx < row_max) break; refresh_page(page, +DUMP_SIZE); str = g_strdup_printf("%i", row_max); path = gtk_tree_path_new_from_string(str); g_free(str); gtk_tree_view_set_cursor(view, path, NULL, FALSE); return FALSE; case GDK_n: search_next(); return TRUE; case GDK_a: case GDK_A: if(event->state & GDK_CONTROL_MASK) { on_go_to_address2_activate((GtkMenuItem *)widget, user_data); return TRUE; } case GDK_f: case GDK_F: if(event->state & GDK_CONTROL_MASK) { on_find1_activate((GtkMenuItem *)widget, user_data); return TRUE; } case GDK_plus: dbgmem_button1_clicked(NULL, NULL); return FALSE; case GDK_minus: dbgmem_button2_clicked(NULL, NULL); return FALSE; default: return FALSE; } return FALSE; }