Changeset b8b742e in mainline
- Timestamp:
- 2012-08-15T23:03:55Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b224a3e, c8444d8
- Parents:
- a44abb3e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/edit/edit.c
ra44abb3e rb8b742e 126 126 static int file_save_range(char const *fname, spt_t const *spos, 127 127 spt_t const *epos); 128 static char *filename_prompt(char const *prompt, char const *init_value);129 128 static char *range_get_str(spt_t const *spos, spt_t const *epos); 129 130 static char *prompt(char const *prompt, char const *init_value); 130 131 131 132 static void pane_text_display(void); … … 142 143 static void caret_move_word_left(void); 143 144 static void caret_move_word_right(void); 145 static void caret_move_to_line(int row); 146 static void caret_go_to_line_ask(void); 144 147 145 148 static bool selection_active(void); … … 404 407 caret_move_word_left(); 405 408 break; 409 case KC_L: 410 caret_go_to_line_ask(); 411 break; 406 412 default: 407 413 break; … … 520 526 char *fname; 521 527 522 fname = filename_prompt("Save As", old_fname);528 fname = prompt("Save As", old_fname); 523 529 if (fname == NULL) { 524 530 status_display("Save cancelled."); … … 535 541 } 536 542 537 /** Ask for a file name. */538 static char * filename_prompt(char const *prompt, char const *init_value)543 /** Ask for a string. */ 544 static char *prompt(char const *prompt, char const *init_value) 539 545 { 540 546 kbd_event_t ev; … … 1078 1084 } 1079 1085 1086 /** Change the caret position to a beginning of a given line 1087 */ 1088 static void caret_move_to_line(int row) 1089 { 1090 spt_t pt; 1091 coord_t coord; 1092 int num_rows; 1093 1094 tag_get_pt(&pane.caret_pos, &pt); 1095 spt_get_coord(&pt, &coord); 1096 coord.row = row; 1097 coord.column = 1; 1098 1099 /* Clamp coordinates. */ 1100 if (coord.row < 1) coord.row = 1; 1101 sheet_get_num_rows(&doc.sh, &num_rows); 1102 if (coord.row > num_rows) coord.row = num_rows; 1103 1104 /* 1105 * Select the point before the character at the designated 1106 * coordinates. The character can be wider than one cell (e.g. tab). 1107 */ 1108 sheet_get_cell_pt(&doc.sh, &coord, dir_before, &pt); 1109 sheet_remove_tag(&doc.sh, &pane.caret_pos); 1110 sheet_place_tag(&doc.sh, &pt, &pane.caret_pos); 1111 1112 /* Set the new value for @c ideal_column. */ 1113 spt_get_coord(&pt, &coord); 1114 pane.ideal_column = coord.column; 1115 1116 caret_update(); 1117 } 1118 1119 /** Ask for line and go to it. */ 1120 static void caret_go_to_line_ask(void) 1121 { 1122 char *sline; 1123 1124 sline = prompt("Go to line", ""); 1125 if (sline == NULL) { 1126 status_display("Go to line cancelled."); 1127 return; 1128 } 1129 1130 char *endptr; 1131 int line = strtol(sline, &endptr, 10); 1132 if (*endptr != '\0') { 1133 status_display("Invalid number entered."); 1134 return; 1135 } 1136 1137 caret_move_to_line(line); 1138 } 1139 1140 1080 1141 /** Check for non-empty selection. */ 1081 1142 static bool selection_active(void)
Note:
See TracChangeset
for help on using the changeset viewer.