Changeset b4b5f6a4 in mainline
- Timestamp:
- 2021-09-26T07:15:58Z (3 years ago)
- Branches:
- master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2f910b7
- Parents:
- 8e253ac
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/edit/edit.c
r8e253ac rb4b5f6a4 61 61 #include <ui/menubar.h> 62 62 #include <ui/menuentry.h> 63 #include <ui/promptdialog.h> 63 64 #include <ui/resource.h> 64 65 #include <ui/ui.h> … … 268 269 }; 269 270 271 static void go_to_line_dialog_bok(ui_prompt_dialog_t *, void *, const char *); 272 static void go_to_line_dialog_bcancel(ui_prompt_dialog_t *, void *); 273 static void go_to_line_dialog_close(ui_prompt_dialog_t *, void *); 274 275 static ui_prompt_dialog_cb_t go_to_line_dialog_cb = { 276 .bok = go_to_line_dialog_bok, 277 .bcancel = go_to_line_dialog_bcancel, 278 .close = go_to_line_dialog_close 279 }; 270 280 271 281 int main(int argc, char *argv[]) … … 1045 1055 return EOK; 1046 1056 } 1047 1048 1057 1049 1058 /** Display pane text. … … 1609 1618 static void caret_go_to_line_ask(void) 1610 1619 { 1611 char *sline; 1612 1613 sline = prompt("Go to line", ""); 1614 if (sline == NULL) { 1615 status_display("Go to line cancelled."); 1620 ui_prompt_dialog_params_t pdparams; 1621 ui_prompt_dialog_t *dialog; 1622 errno_t rc; 1623 1624 ui_prompt_dialog_params_init(&pdparams); 1625 pdparams.caption = "Go To Line"; 1626 pdparams.prompt = "Line Number"; 1627 1628 rc = ui_prompt_dialog_create(edit.ui, &pdparams, &dialog); 1629 if (rc != EOK) { 1630 printf("Error creating prompt dialog.\n"); 1616 1631 return; 1617 1632 } 1618 1633 1619 char *endptr; 1620 int line = strtol(sline, &endptr, 10); 1621 if (*endptr != '\0') { 1622 free(sline); 1623 status_display("Invalid number entered."); 1624 return; 1625 } 1626 free(sline); 1627 1628 caret_move_absolute(line, pane.ideal_column, dir_before, false); 1634 ui_prompt_dialog_set_cb(dialog, &go_to_line_dialog_cb, &edit); 1629 1635 } 1630 1636 … … 2131 2137 const char *fname) 2132 2138 { 2139 edit_t *edit = (edit_t *)arg; 2140 gfx_context_t *gc = ui_window_get_gc(edit->window); 2133 2141 char *cname; 2134 2142 errno_t rc; 2135 2143 2136 2144 ui_file_dialog_destroy(dialog); 2145 // TODO Smarter cursor management 2146 pane.rflags |= REDRAW_CARET; 2147 (void) pane_update(&pane); 2148 gfx_cursor_set_visible(gc, true); 2137 2149 2138 2150 cname = str_dup(fname); … … 2160 2172 { 2161 2173 edit_t *edit = (edit_t *)arg; 2162 2163 (void)edit; 2174 gfx_context_t *gc = ui_window_get_gc(edit->window); 2175 2164 2176 ui_file_dialog_destroy(dialog); 2177 // TODO Smarter cursor management 2178 pane.rflags |= REDRAW_CARET; 2179 (void) pane_update(&pane); 2180 gfx_cursor_set_visible(gc, true); 2165 2181 } 2166 2182 … … 2173 2189 { 2174 2190 edit_t *edit = (edit_t *)arg; 2175 2176 (void)edit; 2191 gfx_context_t *gc = ui_window_get_gc(edit->window); 2192 2177 2193 ui_file_dialog_destroy(dialog); 2194 // TODO Smarter cursor management 2195 pane.rflags |= REDRAW_CARET; 2196 (void) pane_update(&pane); 2197 gfx_cursor_set_visible(gc, true); 2198 } 2199 2200 /** Go To Line dialog OK button press. 2201 * 2202 * @param dialog Go To Line dialog 2203 * @param arg Argument (ui_demo_t *) 2204 * @param text Submitted text 2205 */ 2206 static void go_to_line_dialog_bok(ui_prompt_dialog_t *dialog, void *arg, 2207 const char *text) 2208 { 2209 edit_t *edit = (edit_t *) arg; 2210 gfx_context_t *gc = ui_window_get_gc(edit->window); 2211 char *endptr; 2212 int line; 2213 2214 ui_prompt_dialog_destroy(dialog); 2215 line = strtol(text, &endptr, 10); 2216 if (*endptr != '\0') { 2217 status_display("Invalid number entered."); 2218 return; 2219 } 2220 2221 caret_move_absolute(line, pane.ideal_column, dir_before, false); 2222 // TODO Smarter cursor management 2223 (void) pane_update(&pane); 2224 gfx_cursor_set_visible(gc, true); 2225 (void) gfx_update(gc); 2226 } 2227 2228 /** Go To Line dialog cancel button press. 2229 * 2230 * @param dialog File dialog 2231 * @param arg Argument (ui_demo_t *) 2232 */ 2233 static void go_to_line_dialog_bcancel(ui_prompt_dialog_t *dialog, void *arg) 2234 { 2235 edit_t *edit = (edit_t *) arg; 2236 gfx_context_t *gc = ui_window_get_gc(edit->window); 2237 2238 ui_prompt_dialog_destroy(dialog); 2239 // TODO Smarter cursor management 2240 pane.rflags |= REDRAW_CARET; 2241 (void) pane_update(&pane); 2242 gfx_cursor_set_visible(gc, true); 2243 } 2244 2245 /** Go To Line dialog close request. 2246 * 2247 * @param dialog File dialog 2248 * @param arg Argument (ui_demo_t *) 2249 */ 2250 static void go_to_line_dialog_close(ui_prompt_dialog_t *dialog, void *arg) 2251 { 2252 edit_t *edit = (edit_t *) arg; 2253 gfx_context_t *gc = ui_window_get_gc(edit->window); 2254 2255 ui_prompt_dialog_destroy(dialog); 2256 // TODO Smarter cursor management 2257 pane.rflags |= REDRAW_CARET; 2258 (void) pane_update(&pane); 2259 gfx_cursor_set_visible(gc, true); 2178 2260 } 2179 2261
Note:
See TracChangeset
for help on using the changeset viewer.