/* Handler for control sequencie introducer, "ESC [" */ static void control_escape_csi(char ch) { switch (ch) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': console->params[console->param_count] = 10 * console->params[console->param_count] + (ch - '0'); break; case ';': if (console->param_count + 1 == CONSOLE_MAX_PARAMS) log_error("Too many console parameters.\n"); else console->param_count++; break; case 'A': /* CUU */ move_up(console->params[0]? console->params[0]: 1); console->processor = NULL; break; case 'B': /* CUD */ case 'e': /* VPR */ move_down(console->params[0]? console->params[0]: 1); console->processor = NULL; break; case 'C': /* CUF */ case 'a': /* HPR */ move_right(console->params[0]? console->params[0]: 1); console->processor = NULL; break; case 'D': /* CUB */ move_left(console->params[0]? console->params[0]: 1); console->processor = NULL; break; case 'd': /* VPA */ { int y = console->params[0]? console->params[0]: 1; if (y > console->height) y = console->height; set_pos(console->x, y - 1); console->processor = NULL; break; } case 'G': /* CHA */ case '`': /* HPA */ { int x = console->params[0] ? console->params[0] : 1; if (x > console->width) x = console->width; set_pos(x - 1, console->y); console->processor = NULL; break; } case 'H': case 'f': /* Zero or one both represents the first row/column */ if (console->params[0] > 0) console->params[0]--; if (console->params[1] > 0) console->params[1]--; if (console->origin_mode) set_pos(console->params[1], console->scroll_top + console->params[0]); else set_pos(console->params[1], console->params[0]); console->processor = NULL; break; case 'h': if (console->csi_prefix == '?') for (int i = 0; i <= console->param_count; i++) change_private_mode(console->params[i], 1); else for (int i = 0; i <= console->param_count; i++) change_mode(console->params[i], 1); console->processor = NULL; break; case 'J': erase_screen(console->params[0]); console->processor = NULL; break; case 'K': erase_line(console->params[0]); console->processor = NULL; break; case 'l': if (console->csi_prefix == '?') for (int i = 0; i <= console->param_count; i++) change_private_mode(console->params[i], 0); else for (int i = 0; i <= console->param_count; i++) change_mode(console->params[i], 0); console->processor = NULL; break; case 'L': /* IL */ insert_line(console->params[0]? console->params[0]: 1); console->processor = NULL; break; case 'M': /* DL */ delete_line(console->params[0]? console->params[0]: 1); console->processor = NULL; break; case '@': /* ICH */ insert_character(console->params[0]? console->params[0]: 1); console->processor = NULL; break; case 'P': /* DCH */ delete_character(console->params[0]? console->params[0]: 1); console->processor = NULL; break; case 'c': if (console->csi_prefix == '>') /* DA2 */ { if (console->params[0] == 0) console_add_input("\x1B[>61;95;0c", 11); else log_warning("DA2 parameter is not zero.\n"); } else /* DA1 */ { if (console->params[0] == 0) log_error("DA1 not supported.\n"); else log_warning("DA1 parameter is not zero.\n"); } console->processor = NULL; break; case 'm': for (int i = 0; i <= console->param_count; i++) { switch (console->params[i]) { case 0: /* Reset */ console->bright = 0; console->reverse = 0; console->foreground = 7; console->background = 0; break; case 1: console->bright = 1; break; case 2: console->bright = 0; break; case 7: console->reverse = 1; break; case 27: console->reverse = 0; break; case 30: case 31: case 32: case 33: case 34: case 35: case 36: case 37: console->foreground = console->params[i] - 30; break; case 40: case 41: case 42: case 43: case 44: case 45: case 46: case 47: console->background = console->params[i] - 40; break; default: log_error("Unknown console attribute: %d\n", console->params[i]); } } /* Set updated text attribute */ SetConsoleTextAttribute(console->out, get_text_attribute(console)); console->processor = NULL; break; case 'r': if (console->params[0] == 0) console->params[0] = 1; if (console->params[1] == 0) console->params[1] = console->height; console->scroll_full_screen = (console->params[0] == 1 && console->params[1] == console->height); console->scroll_top = console->params[0] - 1; console->scroll_bottom = console->params[1] - 1; set_pos(0, 0); console->processor = NULL; break; case 'S': /* SU */ scroll_up(console->params[0]? console->params[0]: 1); console->processor = NULL; break; case '?': console->csi_prefix = '?'; break; case '>': console->csi_prefix = '?'; break; default: log_error("control_escape_csi(): Unhandled character %c\n", ch); console->processor = NULL; } }
int main (void) { char* requete; query* q=NULL; line* ligne= create_line(7);; data *d; system("clear"); printf(" Test et simultation d'une session d'utilisation de littleBD avec un pronpteur \n"); printf(" Exercice 1 : Comprehension LOAD SAVE EXIT SELECT * FROM Table \n\n"); requete = "LOAD basededonnee.sql"; testfusion(requete,q); requete = "LOAD basededonnee.sql.old"; testfusion(requete,q); printf(" /*prise en charge des fichiers.old */ \n"); pause(); requete = "SAVE"; testfusion(requete,q); requete = "EXIT"; testfusion(requete,q); requete = "SELECT * FROM Table"; testfusion(requete,q); pause(); printf(" Exercice 2 : Fusion de query et de la structure \n\n"); printf(" Requete implemente CREATE TABLE \n"); requete = "CREATE TABLE toto ( id INT, ville CHAR)"; testfusion(requete,q); printf(" Comprehenion et restitution des autres requetes : \n"); requete = "DELETE FROM toto WHERE id = '1'"; testfusion(requete,q); requete = "INSERT INTO toto ( id , ville ) VALUES ( 1 , 'c' )"; testfusion(requete,q); pause(); requete = "DROP TABLE toto"; testfusion(requete,q); requete = "SELECT id FROM toto WHERE ! ( id > 1 AND c = 'c' )"; testfusion(requete,q); pause(); printf(" Exercice 3.1 : Effacer une ligne \n\n"); printf(" Create Line ( 7 ) \n"); print_line (ligne); printf(" Remplissage de la ligne ... \n"); d=makeInt(1); update_line(ligne,*d,1); d=makeCar('c'); update_line(ligne,*d,2); d=makeInt(345); update_line(ligne,*d,3); d=makeInt(2113); update_line(ligne,*d,4); d=makeInt(303); update_line(ligne,*d,6); print_line(ligne); printf("\n Deleteline \n"); delete_line(ligne); print_line(ligne); return EXIT_SUCCESS; }
int main() { int i, tmp; text_t *txt1, *txt2; char *c; printf("starting \n"); txt1 = create_text(); txt2 = create_text(); append_line(txt1, "line one" ); if( (tmp = length_text(txt1)) != 1) { printf("Test 1: length should be 1, is %d\n", tmp); exit(-1); } append_line(txt1, "line hundred" ); insert_line(txt1, 2, "line ninetynine" ); insert_line(txt1, 2, "line ninetyeight" ); insert_line(txt1, 2, "line ninetyseven" ); insert_line(txt1, 2, "line ninetysix" ); insert_line(txt1, 2, "line ninetyfive" ); for( i = 2; i <95; i++ ) insert_line(txt1, 2, "some filler line between 1 and 95" ); if( (tmp = length_text(txt1)) != 100) { printf("Test 2: length should be 100, is %d\n", tmp); exit(-1); } printf("found at line 1: %s\n",get_line(txt1, 1)); printf("found at line 2: %s\n",get_line(txt1, 2)); printf("found at line 99: %s\n",get_line(txt1, 99)); printf("found at line 100: %s\n",get_line(txt1,100)); for(i=1; i<=10000; i++) { if( i%2==1 ) append_line(txt2, "A"); else append_line(txt2, "B"); } if( (tmp = length_text(txt2)) != 10000) { printf("Test 3: length should be 10000, is %d\n", tmp); exit(-1); } c = get_line(txt2, 9876 ); if( *c != 'B') { printf("Test 4: line 9876 of txt2 should be B, found %s\n", c); exit(-1); } for( i= 10000; i > 1; i-=2 ) { c = delete_line(txt2, i); if( *c != 'B') { printf("Test 5: line %d of txt2 should be B, found %s\n", i, c); exit(-1); } append_line( txt2, c ); } for( i=1; i<= 5000; i++ ) { c = get_line(txt2, i); if( *c != 'A') { printf("Test 6: line %d of txt2 should be A, found %s\n", i, c); exit(-1); } } for( i=1; i<= 5000; i++ ) delete_line(txt2, 1 ); for( i=1; i<= 5000; i++ ) { c = get_line(txt2, i); if( *c != 'B') { printf("Test 7: line %d of txt2 should be B, found %s\n", i, c); exit(-1); } } set_line(txt1, 100, "the last line"); for( i=99; i>=1; i-- ) delete_line(txt1, i ); printf("found at the last line: %s\n",get_line(txt1, 1)); }
static gboolean handle_backspace( AutocloseUserData *data, ScintillaObject *sci, gchar ch, gchar *ch_left, gchar *ch_right, GdkEventKey *event, gint indent_width) { gint pos = sci_get_current_position(sci); gint end_pos; gint line_start, line_end, line; gint i; if (!ac_info->delete_pairing_brace) return AC_CONTINUE_ACTION; ch = char_at(sci, pos - 1); if (!check_chars(sci, ch, ch_left, ch_right)) return AC_CONTINUE_ACTION; if (event->state & GDK_SHIFT_MASK) { if ((ch_left[0] == ch || ch_right[0] == ch) && ac_info->bcksp_remove_pair) { end_pos = sci_find_matching_brace(sci, pos - 1); if (-1 == end_pos) return AC_CONTINUE_ACTION; sci_start_undo_action(sci); line_start = sci_get_line_from_position(sci, pos); line_end = sci_get_line_from_position(sci, end_pos); SSM(sci, SCI_DELETERANGE, end_pos, 1); if (end_pos < pos) pos--; SSM(sci, SCI_DELETERANGE, pos - 1, 1); /* remove indentation magick */ if (char_is_curly_bracket(ch)) { if (line_start == line_end) goto final; if (line_start > line_end) { line = line_end; line_end = line_start; line_start = line; } if (blank_line(sci, line_start)) { delete_line(sci, line_start); line_end--; } else line_start++; if (blank_line(sci, line_end)) delete_line(sci, line_end); line_end--; /* unindent */ for (i = line_start; i <= line_end; i++) { unindent_line(sci, i, indent_width); } } final: sci_end_undo_action(sci); return AC_STOP_ACTION; }