Ticket #319: 319-flow-column-insertion.patch
File 319-flow-column-insertion.patch, 7.6 KB (added by vit_r, 14 years ago) |
---|
-
edit/edit.c
From 59e5cdcb1c98089390853bcbe29dc32aefb03d9e Mon Sep 17 00:00:00 2001 From: Vit Rosin <vit_r@list.ru> Date: Tue, 3 Nov 2009 20:50:38 +0000 Subject: [PATCH] flow column insertion --- edit/edit.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- edit/edit.h | 5 +-- edit/editcmd.c | 24 +++++++++++++------ 3 files changed, 84 insertions(+), 12 deletions(-) diff --git a/edit/edit.c b/edit/edit.c index e239c0c..1cc642e 100644
a b const char *option_whole_chars_search = "0123456789abcdefghijklmnopqrstuvwxyz_"; 87 87 char *option_backup_ext = NULL; 88 88 89 89 int edit_stack_iterator = 0; 90 static unsigned long pasted_from_X_buf; 90 91 edit_stack_type edit_history_moveto [MAX_HISTORY_MOVETO]; 91 92 /* magic sequense for say than block is vertical */ 92 93 const char VERTICAL_MAGIC[] = {'\1', '\1', '\1', '\1', '\n'}; … … int 478 479 edit_insert_file (WEdit *edit, const char *filename) 479 480 { 480 481 char *p; 482 pasted_from_X_buf = 0; 481 483 if ((p = edit_get_filter (filename))) { 482 484 FILE *f; 483 485 long current = edit->curs1; … … edit_insert_file (WEdit *edit, const char *filename) 526 528 for (i = 0; i < blocklen; i++) 527 529 edit_insert (edit, buf[i]); 528 530 } 531 pasted_from_X_buf = edit->curs1 - current; 529 532 } 530 533 edit_cursor_move (edit, current - edit->curs1); 531 534 g_free (buf); … … static void edit_goto_matching_bracket (WEdit *edit) 2529 2532 */ 2530 2533 void edit_execute_key_command (WEdit *edit, int command, int char_for_insertion) 2531 2534 { 2535 static unsigned int go_to_SIstart_col = 0; 2536 static unsigned int go_to_CMstart_col = 0; 2537 2532 2538 if (command == CK_Begin_Record_Macro) { 2533 2539 edit->macro_i = 0; 2534 2540 edit->force |= REDRAW_CHAR_ONLY | REDRAW_LINE; … … void edit_execute_key_command (WEdit *edit, int command, int char_for_insertion) 2549 2555 edit_push_key_press (edit); 2550 2556 2551 2557 edit_execute_cmd (edit, command, char_for_insertion); 2558 2559 switch (command) { 2560 case CK_Copy: 2561 case CK_Move: 2562 go_to_CMstart_col = 0; 2563 go_to_SIstart_col = 0; 2564 if ( ! column_highlighting && buf_stored_size) { 2565 edit_mark_cmd (edit, 1); 2566 edit_mark_cmd (edit, 0); 2567 edit_cursor_move (edit, buf_stored_size); 2568 edit_mark_cmd (edit, 0); 2569 edit->force |= REDRAW_PAGE; 2570 edit_update_screen (edit); 2571 if (edit->curs_line > (edit->start_line 2572 + edit->num_widget_lines - 3)) { 2573 edit_move_display (edit, edit->start_line + 2); 2574 edit->force |= REDRAW_PAGE; 2575 } 2576 go_to_CMstart_col = 1; 2577 } 2578 break; 2579 case CK_XPaste: 2580 go_to_CMstart_col = 0; 2581 go_to_SIstart_col = 0; 2582 if ( ! column_highlighting && pasted_from_X_buf) { 2583 edit_mark_cmd (edit, 1); 2584 edit_mark_cmd (edit, 0); 2585 edit_cursor_move (edit, pasted_from_X_buf); 2586 edit_mark_cmd (edit, 0); 2587 edit->force |= REDRAW_PAGE; 2588 edit_update_screen (edit); 2589 if (edit->curs_line > (edit->start_line 2590 + edit->num_widget_lines - 3)) { 2591 edit_move_display (edit, edit->start_line + 2); 2592 edit->force |= REDRAW_PAGE; 2593 } 2594 go_to_SIstart_col = 1; 2595 } 2596 break; 2597 case CK_Up: 2598 if ( ! column_highlighting) { 2599 if (go_to_CMstart_col || go_to_SIstart_col) { 2600 long start_mark, end_mark; 2601 eval_marks (edit, &start_mark, &end_mark); 2602 if (end_mark - start_mark) { 2603 edit_cursor_move (edit, start_mark - edit->curs1); 2604 if (edit->curs_line) 2605 edit_move_to_line (edit, edit->curs_line - 1); 2606 if (edit->curs_line < (edit->start_line + 1)) 2607 edit_move_display (edit, edit->curs_line - 1); 2608 edit->force |= REDRAW_PAGE; 2609 } 2610 } 2611 } 2612 default: 2613 go_to_CMstart_col = 0; 2614 go_to_SIstart_col = 0; 2615 } 2616 2552 2617 if (column_highlighting) 2553 2618 edit->force |= REDRAW_PAGE; 2554 2619 } … … edit_execute_cmd (WEdit *edit, int command, int char_for_insertion) 2581 2646 edit->highlight = 1; 2582 2647 } else { /* any other command */ 2583 2648 if (edit->highlight) 2584 edit_mark_cmd (edit, 0); /* clear*/2649 edit_mark_cmd (edit, 0); /* marking on */ 2585 2650 edit->highlight = 0; 2586 2651 } 2587 2652 -
edit/edit.h
diff --git a/edit/edit.h b/edit/edit.h index 0891801..f26bd5b 100644
a b extern int option_save_mode; 53 53 extern int option_save_position; 54 54 extern int option_syntax_highlighting; 55 55 extern char *option_backup_ext; 56 57 56 extern int edit_confirm_save; 58 59 57 extern int visible_tabs; 60 58 extern int visible_tws; 61 62 59 extern int simple_statusbar; 63 60 extern int option_check_nl_at_eof; 64 61 62 unsigned long buf_stored_size; 63 65 64 /* used in main() */ 66 65 void edit_stack_init (void); 67 66 void edit_stack_free (void); -
edit/editcmd.c
diff --git a/edit/editcmd.c b/edit/editcmd.c index 48f1db6..c328def 100644
a b edit_insert_column_of_text_from_file (WEdit * edit, int file) 1167 1167 void 1168 1168 edit_block_copy_cmd (WEdit *edit) 1169 1169 { 1170 long start_mark, end_mark , current = edit->curs1;1170 long start_mark, end_mark; 1171 1171 int size; 1172 1172 unsigned char *copy_buf; 1173 1173 1174 buf_stored_size = 0; 1175 1174 1176 edit_update_curs_col (edit); 1175 1177 if (eval_marks (edit, &start_mark, &end_mark)) 1176 1178 return; … … edit_block_copy_cmd (WEdit *edit) 1185 1187 edit_insert_column_of_text (edit, copy_buf, size, 1186 1188 abs (edit->column2 - edit->column1)); 1187 1189 } else { 1190 buf_stored_size = (long) size; 1188 1191 while (size--) 1189 1192 edit_insert_ahead (edit, copy_buf[size]); 1190 1193 } … … edit_block_copy_cmd (WEdit *edit) 1196 1199 edit_set_markers (edit, 0, 0, 0, 0); 1197 1200 edit_push_action (edit, COLUMN_ON); 1198 1201 column_highlighting = 0; 1199 } else if (start_mark < current && end_mark > current) 1200 edit_set_markers (edit, start_mark, 1201 end_mark + end_mark - start_mark, 0, 0); 1202 buf_stored_size = 0; 1203 } 1202 1204 1203 1205 edit->force |= REDRAW_PAGE; 1204 1206 } … … edit_block_move_cmd (WEdit *edit) 1214 1216 int deleted = 0; 1215 1217 int x = 0; 1216 1218 1219 buf_stored_size = 0; 1220 1217 1221 if (eval_marks (edit, &start_mark, &end_mark)) 1218 1222 return; 1223 1219 1224 if (column_highlighting) { 1220 1225 edit_update_curs_col (edit); 1221 1226 x = edit->curs_col; … … edit_block_move_cmd (WEdit *edit) 1226 1231 } else if (start_mark <= edit->curs1 && end_mark >= edit->curs1) 1227 1232 return; 1228 1233 1229 if ((end_mark - start_mark) > option_max_undo / 2) 1234 buf_stored_size = end_mark - start_mark; 1235 1236 if (buf_stored_size > option_max_undo / 2) 1230 1237 if (edit_query_dialog2 1231 1238 (_("Warning"), 1232 1239 _ … … edit_block_move_cmd (WEdit *edit) 1269 1276 edit_set_markers (edit, 0, 0, 0, 0); 1270 1277 edit_push_action (edit, COLUMN_ON); 1271 1278 column_highlighting = 0; 1279 buf_stored_size = 0; 1272 1280 } else { 1273 copy_buf = g_malloc ( end_mark - start_mark);1281 copy_buf = g_malloc (buf_stored_size); 1274 1282 edit_cursor_move (edit, start_mark - edit->curs1); 1275 1283 edit_scroll_screen_over_cursor (edit); 1276 1284 count = start_mark; … … edit_block_move_cmd (WEdit *edit) 1282 1290 edit_cursor_move (edit, 1283 1291 current - edit->curs1 - 1284 1292 (((current - edit->curs1) > 1285 0) ? end_mark - start_mark: 0));1293 0) ? buf_stored_size : 0)); 1286 1294 edit_scroll_screen_over_cursor (edit); 1287 1295 while (count-- > start_mark) 1288 1296 edit_insert_ahead (edit, copy_buf[end_mark - count - 1]); 1289 1297 edit_set_markers (edit, edit->curs1, 1290 edit->curs1 + end_mark - start_mark, 0, 0);1298 edit->curs1 + buf_stored_size, 0, 0); 1291 1299 } 1292 1300 edit_scroll_screen_over_cursor (edit); 1293 1301 g_free (copy_buf);