Changes in uspace/app/edit/edit.c [3c22438a:994f87b] in mainline
- File:
-
- 1 edited
-
uspace/app/edit/edit.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/edit/edit.c
r3c22438a r994f87b 1 1 /* 2 * Copyright (c) 202 6Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * Copyright (c) 2012 Martin Sucha 4 4 * All rights reserved. … … 240 240 static void edit_ui_destroy(edit_t *); 241 241 242 static void edit_wnd_resize(ui_window_t *, void *);243 242 static void edit_wnd_close(ui_window_t *, void *); 244 243 static void edit_wnd_focus(ui_window_t *, void *, unsigned); … … 247 246 248 247 static ui_window_cb_t edit_window_cb = { 249 .resize = edit_wnd_resize,250 248 .close = edit_wnd_close, 251 249 .focus = edit_wnd_focus, … … 365 363 edit_ui_destroy(&edit); 366 364 return 0; 367 }368 369 /** Set menu bar rectangle.370 *371 * Set the menu bar rectangle based on editor window dimensions.372 * Used when window is created or resized.373 *374 * @param edit Editor375 */376 static void edit_menubar_set_rect(edit_t *edit)377 {378 gfx_rect_t arect;379 gfx_rect_t rect;380 381 ui_window_get_app_rect(edit->window, &arect);382 383 rect.p0 = arect.p0;384 rect.p1.x = arect.p1.x;385 rect.p1.y = arect.p0.y + 1;386 ui_menu_bar_set_rect(edit->menubar, &rect);387 }388 389 /** Set status bar rectangle.390 *391 * Set the status bar rectangle based on editor window dimensions.392 * Used when window is created or resized.393 *394 * @param edit Editor395 */396 static void edit_status_set_rect(edit_t *edit)397 {398 gfx_rect_t arect;399 gfx_rect_t rect;400 401 ui_window_get_app_rect(edit->window, &arect);402 rect.p0.x = arect.p0.x;403 rect.p0.y = arect.p1.y - 1;404 rect.p1 = arect.p1;405 ui_label_set_rect(edit->status, &rect);406 365 } 407 366 … … 436 395 ui_menu_entry_t *mssep = NULL; 437 396 ui_menu_entry_t *mgoto = NULL; 397 gfx_rect_t arect; 398 gfx_rect_t rect; 438 399 439 400 rc = ui_create(UI_CONSOLE_DEFAULT, &edit->ui); … … 621 582 ui_menu_entry_set_cb(mgoto, edit_search_go_to_line, (void *) edit); 622 583 623 edit_menubar_set_rect(edit); 584 ui_window_get_app_rect(edit->window, &arect); 585 586 rect.p0 = arect.p0; 587 rect.p1.x = arect.p1.x; 588 rect.p1.y = arect.p0.y + 1; 589 ui_menu_bar_set_rect(edit->menubar, &rect); 624 590 625 591 rc = ui_fixed_add(fixed, ui_menu_bar_ctl(edit->menubar)); … … 647 613 } 648 614 649 edit_status_set_rect(edit); 615 rect.p0.x = arect.p0.x; 616 rect.p0.y = arect.p1.y - 1; 617 rect.p1 = arect.p1; 618 ui_label_set_rect(edit->status, &rect); 650 619 651 620 rc = ui_fixed_add(fixed, ui_label_ctl(edit->status)); … … 1233 1202 } 1234 1203 1235 static void pane_set_rect(pane_t *pane) 1236 { 1204 /** Initialize pane. 1205 * 1206 * TODO: Replace with pane_create() that allocates the pane. 1207 * 1208 * @param window Editor window 1209 * @param pane Pane 1210 * @return EOK on success or an error code 1211 */ 1212 static errno_t pane_init(ui_window_t *window, pane_t *pane) 1213 { 1214 errno_t rc; 1237 1215 gfx_rect_t arect; 1238 1216 1239 ui_window_get_app_rect(pane->window, &arect); 1217 pane->control = NULL; 1218 pane->color = NULL; 1219 pane->sel_color = NULL; 1220 1221 rc = ui_control_new(&pane_ctl_ops, (void *) pane, &pane->control); 1222 if (rc != EOK) 1223 goto error; 1224 1225 rc = gfx_color_new_ega(0x07, &pane->color); 1226 if (rc != EOK) 1227 goto error; 1228 1229 rc = gfx_color_new_ega(0x1e, &pane->sel_color); 1230 if (rc != EOK) 1231 goto error; 1232 1233 pane->res = ui_window_get_res(window); 1234 pane->window = window; 1235 1236 ui_window_get_app_rect(window, &arect); 1240 1237 pane->rect.p0.x = arect.p0.x; 1241 1238 pane->rect.p0.y = arect.p0.y + 1; … … 1245 1242 pane->columns = pane->rect.p1.x - pane->rect.p0.x; 1246 1243 pane->rows = pane->rect.p1.y - pane->rect.p0.y; 1247 } 1248 1249 /** Initialize pane. 1250 * 1251 * TODO: Replace with pane_create() that allocates the pane. 1252 * 1253 * @param window Editor window 1254 * @param pane Pane 1255 * @return EOK on success or an error code 1256 */ 1257 static errno_t pane_init(ui_window_t *window, pane_t *pane) 1258 { 1259 errno_t rc; 1260 1261 pane->control = NULL; 1262 pane->color = NULL; 1263 pane->sel_color = NULL; 1264 1265 rc = ui_control_new(&pane_ctl_ops, (void *) pane, &pane->control); 1266 if (rc != EOK) 1267 goto error; 1268 1269 rc = gfx_color_new_ega(0x07, &pane->color); 1270 if (rc != EOK) 1271 goto error; 1272 1273 rc = gfx_color_new_ega(0x1e, &pane->sel_color); 1274 if (rc != EOK) 1275 goto error; 1276 1277 pane->res = ui_window_get_res(window); 1278 pane->window = window; 1279 1280 pane_set_rect(pane); 1244 1281 1245 return EOK; 1282 1246 error: … … 1292 1256 1293 1257 return rc; 1294 }1295 1296 static void pane_resize(pane_t *pane)1297 {1298 pane_set_rect(pane);1299 1300 /* Scroll in case cursor is now outside of the editor pane. */1301 caret_move_relative(0, 0, dir_before, true);1302 1303 pane_caret_display(pane);1304 1258 } 1305 1259 … … 2396 2350 } 2397 2351 2398 /** Window was resized.2399 *2400 * @param window Window2401 * @param arg Argument (edit_t *)2402 */2403 static void edit_wnd_resize(ui_window_t *window, void *arg)2404 {2405 edit_t *edit = (edit_t *) arg;2406 2407 edit_menubar_set_rect(edit);2408 edit_status_set_rect(edit);2409 pane_resize(&pane);2410 }2411 2412 2352 /** Window close request 2413 2353 *
Note:
See TracChangeset
for help on using the changeset viewer.
