Changeset 3c22438a in mainline for uspace/app
- Timestamp:
- 2026-03-09T07:37:31Z (9 days ago)
- Branches:
- master
- Children:
- b979ffb
- Parents:
- 13277e3
- git-author:
- Jiri Svoboda <jiri@…> (2026-03-09 19:37:18)
- git-committer:
- Jiri Svoboda <jiri@…> (2026-03-09 07:37:31)
- File:
-
- 1 edited
-
uspace/app/edit/edit.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/edit/edit.c
r13277e3 r3c22438a 1 1 /* 2 * Copyright (c) 202 4Jiri Svoboda2 * Copyright (c) 2026 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 *); 242 243 static void edit_wnd_close(ui_window_t *, void *); 243 244 static void edit_wnd_focus(ui_window_t *, void *, unsigned); … … 246 247 247 248 static ui_window_cb_t edit_window_cb = { 249 .resize = edit_wnd_resize, 248 250 .close = edit_wnd_close, 249 251 .focus = edit_wnd_focus, … … 363 365 edit_ui_destroy(&edit); 364 366 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 Editor 375 */ 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 Editor 395 */ 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); 365 406 } 366 407 … … 395 436 ui_menu_entry_t *mssep = NULL; 396 437 ui_menu_entry_t *mgoto = NULL; 397 gfx_rect_t arect;398 gfx_rect_t rect;399 438 400 439 rc = ui_create(UI_CONSOLE_DEFAULT, &edit->ui); … … 582 621 ui_menu_entry_set_cb(mgoto, edit_search_go_to_line, (void *) edit); 583 622 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); 623 edit_menubar_set_rect(edit); 590 624 591 625 rc = ui_fixed_add(fixed, ui_menu_bar_ctl(edit->menubar)); … … 613 647 } 614 648 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); 649 edit_status_set_rect(edit); 619 650 620 651 rc = ui_fixed_add(fixed, ui_label_ctl(edit->status)); … … 1202 1233 } 1203 1234 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; 1235 static void pane_set_rect(pane_t *pane) 1236 { 1215 1237 gfx_rect_t arect; 1216 1238 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); 1239 ui_window_get_app_rect(pane->window, &arect); 1237 1240 pane->rect.p0.x = arect.p0.x; 1238 1241 pane->rect.p0.y = arect.p0.y + 1; … … 1242 1245 pane->columns = pane->rect.p1.x - pane->rect.p0.x; 1243 1246 pane->rows = pane->rect.p1.y - pane->rect.p0.y; 1244 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); 1245 1281 return EOK; 1246 1282 error: … … 1256 1292 1257 1293 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); 1258 1304 } 1259 1305 … … 2350 2396 } 2351 2397 2398 /** Window was resized. 2399 * 2400 * @param window Window 2401 * @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 2352 2412 /** Window close request 2353 2413 *
Note:
See TracChangeset
for help on using the changeset viewer.
