source: mainline/uspace/app/uidemo/uidemo.c@ de38873

serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since de38873 was dbb42c9, checked in by Jiri Svoboda <jiri@…>, 4 years ago

Scroll entry text when it is long

Whew! This is so much harder than it looks!

  • Property mode set to 100644
File size: 16.8 KB
Line 
1/*
2 * Copyright (c) 2021 Jiri Svoboda
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup uidemo
30 * @{
31 */
32/** @file User interface demo
33 */
34
35#include <gfx/bitmap.h>
36#include <gfx/coord.h>
37#include <io/pixelmap.h>
38#include <stdio.h>
39#include <stdlib.h>
40#include <str.h>
41#include <ui/entry.h>
42#include <ui/fixed.h>
43#include <ui/image.h>
44#include <ui/label.h>
45#include <ui/menubar.h>
46#include <ui/menuentry.h>
47#include <ui/menu.h>
48#include <ui/msgdialog.h>
49#include <ui/pbutton.h>
50#include <ui/resource.h>
51#include <ui/ui.h>
52#include <ui/window.h>
53#include "uidemo.h"
54
55static errno_t bitmap_moire(gfx_bitmap_t *, gfx_coord_t, gfx_coord_t);
56
57static void wnd_close(ui_window_t *, void *);
58
59static ui_window_cb_t window_cb = {
60 .close = wnd_close
61};
62
63static void pb_clicked(ui_pbutton_t *, void *);
64
65static ui_pbutton_cb_t pbutton_cb = {
66 .clicked = pb_clicked
67};
68
69static void checkbox_switched(ui_checkbox_t *, void *, bool);
70
71static ui_checkbox_cb_t checkbox_cb = {
72 .switched = checkbox_switched
73};
74
75static void rb_selected(ui_rbutton_group_t *, void *, void *);
76
77static ui_rbutton_group_cb_t rbutton_group_cb = {
78 .selected = rb_selected
79};
80
81static void slider_moved(ui_slider_t *, void *, gfx_coord_t);
82
83static ui_slider_cb_t slider_cb = {
84 .moved = slider_moved
85};
86
87static void uidemo_file_message(ui_menu_entry_t *, void *);
88static void uidemo_file_exit(ui_menu_entry_t *, void *);
89
90static void msg_dialog_button(ui_msg_dialog_t *, void *, unsigned);
91static void msg_dialog_close(ui_msg_dialog_t *, void *);
92
93static ui_msg_dialog_cb_t msg_dialog_cb = {
94 .button = msg_dialog_button,
95 .close = msg_dialog_close
96};
97
98/** Horizontal alignment selected by each radio button */
99static const gfx_halign_t uidemo_halign[3] = {
100 gfx_halign_left,
101 gfx_halign_center,
102 gfx_halign_right
103};
104
105/** Window close button was clicked.
106 *
107 * @param window Window
108 * @param arg Argument (demo)
109 */
110static void wnd_close(ui_window_t *window, void *arg)
111{
112 ui_demo_t *demo = (ui_demo_t *) arg;
113
114 ui_quit(demo->ui);
115}
116
117/** Push button was clicked.
118 *
119 * @param pbutton Push button
120 * @param arg Argument (demo)
121 */
122static void pb_clicked(ui_pbutton_t *pbutton, void *arg)
123{
124 ui_demo_t *demo = (ui_demo_t *) arg;
125 errno_t rc;
126
127 if (pbutton == demo->pb1) {
128 rc = ui_entry_set_text(demo->entry, "OK pressed");
129 if (rc != EOK)
130 printf("Error changing entry text.\n");
131 } else {
132 rc = ui_entry_set_text(demo->entry, "Cancel pressed");
133 if (rc != EOK)
134 printf("Error changing entry text.\n");
135 }
136}
137
138/** Check box was switched.
139 *
140 * @param checkbox Check box
141 * @param arg Argument (demo)
142 */
143static void checkbox_switched(ui_checkbox_t *checkbox, void *arg, bool enable)
144{
145 ui_demo_t *demo = (ui_demo_t *) arg;
146
147 ui_entry_set_read_only(demo->entry, enable);
148}
149
150/** Radio button was selected.
151 *
152 * @param rbgroup Radio button group
153 * @param garg Group argument (demo)
154 * @param barg Button argument
155 */
156static void rb_selected(ui_rbutton_group_t *rbgroup, void *garg, void *barg)
157{
158 ui_demo_t *demo = (ui_demo_t *) garg;
159 gfx_halign_t halign = *(gfx_halign_t *) barg;
160
161 ui_entry_set_halign(demo->entry, halign);
162 (void) ui_entry_paint(demo->entry);
163}
164
165/** Slider was moved.
166 *
167 * @param slider Slider
168 * @param arg Argument (demo)
169 * @param pos Position
170 */
171static void slider_moved(ui_slider_t *slider, void *arg, gfx_coord_t pos)
172{
173 ui_demo_t *demo = (ui_demo_t *) arg;
174 char *str;
175 errno_t rc;
176 int rv;
177
178 rv = asprintf(&str, "Slider at %d of %d", (int) pos,
179 ui_slider_length(slider));
180 if (rv < 0) {
181 printf("Out of memory.\n");
182 return;
183 }
184
185 rc = ui_entry_set_text(demo->entry, str);
186 if (rc != EOK)
187 printf("Error changing entry text.\n");
188 (void) ui_entry_paint(demo->entry);
189
190 free(str);
191}
192
193/** File/message menu entry selected.
194 *
195 * @param mentry Menu entry
196 * @param arg Argument (demo)
197 */
198static void uidemo_file_message(ui_menu_entry_t *mentry, void *arg)
199{
200 ui_demo_t *demo = (ui_demo_t *) arg;
201 ui_msg_dialog_params_t mdparams;
202 ui_msg_dialog_t *dialog;
203 errno_t rc;
204
205 ui_msg_dialog_params_init(&mdparams);
206 mdparams.caption = "Message For You";
207 mdparams.text = "Hello, world!";
208
209 rc = ui_msg_dialog_create(demo->ui, &mdparams, &dialog);
210 if (rc != EOK) {
211 printf("Error creating message dialog.\n");
212 return;
213 }
214
215 ui_msg_dialog_set_cb(dialog, &msg_dialog_cb, &demo);
216
217}
218
219/** File/exit menu entry selected.
220 *
221 * @param mentry Menu entry
222 * @param arg Argument (demo)
223 */
224static void uidemo_file_exit(ui_menu_entry_t *mentry, void *arg)
225{
226 ui_demo_t *demo = (ui_demo_t *) arg;
227
228 ui_quit(demo->ui);
229}
230
231/** Message dialog button press.
232 *
233 * @param dialog Message dialog
234 * @param arg Argument (ui_demo_t *)
235 * @param bnum Button number
236 */
237static void msg_dialog_button(ui_msg_dialog_t *dialog, void *arg,
238 unsigned bnum)
239{
240 ui_demo_t *demo = (ui_demo_t *) arg;
241
242 (void) demo;
243 ui_msg_dialog_destroy(dialog);
244}
245
246/** Message dialog close request.
247 *
248 * @param dialog Message dialog
249 * @param arg Argument (ui_demo_t *)
250 */
251static void msg_dialog_close(ui_msg_dialog_t *dialog, void *arg)
252{
253 ui_demo_t *demo = (ui_demo_t *) arg;
254
255 (void) demo;
256 ui_msg_dialog_destroy(dialog);
257}
258
259/** Run UI demo on display server. */
260static errno_t ui_demo(const char *display_spec)
261{
262 ui_t *ui = NULL;
263 ui_wnd_params_t params;
264 ui_window_t *window = NULL;
265 ui_demo_t demo;
266 gfx_rect_t rect;
267 gfx_context_t *gc;
268 ui_resource_t *ui_res;
269 gfx_bitmap_params_t bparams;
270 gfx_bitmap_t *bitmap;
271 gfx_coord2_t off;
272 ui_menu_entry_t *mmsg;
273 ui_menu_entry_t *mfoo;
274 ui_menu_entry_t *mbar;
275 ui_menu_entry_t *mfoobar;
276 ui_menu_entry_t *mexit;
277 ui_menu_entry_t *mabout;
278 errno_t rc;
279
280 rc = ui_create(display_spec, &ui);
281 if (rc != EOK) {
282 printf("Error creating UI on display %s.\n", display_spec);
283 return rc;
284 }
285
286 memset((void *) &demo, 0, sizeof(demo));
287 demo.ui = ui;
288
289 ui_wnd_params_init(&params);
290 params.caption = "UI Demo";
291 params.style |= ui_wds_resizable;
292
293 /* FIXME: Auto layout */
294 if (ui_is_textmode(ui)) {
295 params.rect.p0.x = 0;
296 params.rect.p0.y = 0;
297 params.rect.p1.x = 80;
298 params.rect.p1.y = 25;
299 } else {
300 params.rect.p0.x = 0;
301 params.rect.p0.y = 0;
302 params.rect.p1.x = 220;
303 params.rect.p1.y = 350;
304 }
305
306 rc = ui_window_create(ui, &params, &window);
307 if (rc != EOK) {
308 printf("Error creating window.\n");
309 return rc;
310 }
311
312 ui_window_set_cb(window, &window_cb, (void *) &demo);
313 demo.window = window;
314
315 ui_res = ui_window_get_res(window);
316 gc = ui_window_get_gc(window);
317
318 rc = ui_fixed_create(&demo.fixed);
319 if (rc != EOK) {
320 printf("Error creating fixed layout.\n");
321 return rc;
322 }
323
324 rc = ui_menu_bar_create(ui, window, &demo.mbar);
325 if (rc != EOK) {
326 printf("Error creating menu bar.\n");
327 return rc;
328 }
329
330 rc = ui_menu_create(demo.mbar, "File", &demo.mfile);
331 if (rc != EOK) {
332 printf("Error creating menu.\n");
333 return rc;
334 }
335
336 rc = ui_menu_entry_create(demo.mfile, "Message", "", &mmsg);
337 if (rc != EOK) {
338 printf("Error creating menu.\n");
339 return rc;
340 }
341
342 ui_menu_entry_set_cb(mmsg, uidemo_file_message, (void *) &demo);
343
344 rc = ui_menu_entry_create(demo.mfile, "Foo", "Ctrl-Alt-Del", &mfoo);
345 if (rc != EOK) {
346 printf("Error creating menu.\n");
347 return rc;
348 }
349
350 rc = ui_menu_entry_create(demo.mfile, "Bar", "", &mbar);
351 if (rc != EOK) {
352 printf("Error creating menu.\n");
353 return rc;
354 }
355
356 rc = ui_menu_entry_create(demo.mfile, "Foobar", "", &mfoobar);
357 if (rc != EOK) {
358 printf("Error creating menu.\n");
359 return rc;
360 }
361
362 rc = ui_menu_entry_sep_create(demo.mfile, &mexit);
363 if (rc != EOK) {
364 printf("Error creating menu.\n");
365 return rc;
366 }
367
368 rc = ui_menu_entry_create(demo.mfile, "Exit", "Alt-F4", &mexit);
369 if (rc != EOK) {
370 printf("Error creating menu.\n");
371 return rc;
372 }
373
374 ui_menu_entry_set_cb(mexit, uidemo_file_exit, (void *) &demo);
375
376 rc = ui_menu_create(demo.mbar, "Edit", &demo.medit);
377 if (rc != EOK) {
378 printf("Error creating menu.\n");
379 return rc;
380 }
381
382 rc = ui_menu_create(demo.mbar, "Preferences", &demo.mpreferences);
383 if (rc != EOK) {
384 printf("Error creating menu.\n");
385 return rc;
386 }
387
388 rc = ui_menu_create(demo.mbar, "Help", &demo.mhelp);
389 if (rc != EOK) {
390 printf("Error creating menu.\n");
391 return rc;
392 }
393
394 rc = ui_menu_entry_create(demo.mhelp, "About", "Ctrl-H, F1", &mabout);
395 if (rc != EOK) {
396 printf("Error creating menu.\n");
397 return rc;
398 }
399
400 /* FIXME: Auto layout */
401 if (ui_is_textmode(ui)) {
402 rect.p0.x = 1;
403 rect.p0.y = 2;
404 rect.p1.x = 79;
405 rect.p1.y = 3;
406 } else {
407 rect.p0.x = 4;
408 rect.p0.y = 30;
409 rect.p1.x = 216;
410 rect.p1.y = 52;
411 }
412 ui_menu_bar_set_rect(demo.mbar, &rect);
413
414 rc = ui_fixed_add(demo.fixed, ui_menu_bar_ctl(demo.mbar));
415 if (rc != EOK) {
416 printf("Error adding control to layout.\n");
417 return rc;
418 }
419
420 rc = ui_entry_create(window, "", &demo.entry);
421 if (rc != EOK) {
422 printf("Error creating entry.\n");
423 return rc;
424 }
425
426 /* FIXME: Auto layout */
427 if (ui_is_textmode(ui)) {
428 rect.p0.x = 20;
429 rect.p0.y = 4;
430 rect.p1.x = 60;
431 rect.p1.y = 5;
432 } else {
433 rect.p0.x = 15;
434 rect.p0.y = 53;
435 rect.p1.x = 205;
436 rect.p1.y = 78;
437 }
438
439 ui_entry_set_rect(demo.entry, &rect);
440 ui_entry_set_halign(demo.entry, gfx_halign_center);
441
442 rc = ui_fixed_add(demo.fixed, ui_entry_ctl(demo.entry));
443 if (rc != EOK) {
444 printf("Error adding control to layout.\n");
445 return rc;
446 }
447
448 rc = ui_label_create(ui_res, "Text label", &demo.label);
449 if (rc != EOK) {
450 printf("Error creating label.\n");
451 return rc;
452 }
453
454 /* FIXME: Auto layout */
455 if (ui_is_textmode(ui)) {
456 rect.p0.x = 20;
457 rect.p0.y = 6;
458 rect.p1.x = 60;
459 rect.p1.y = 7;
460 } else {
461 rect.p0.x = 60;
462 rect.p0.y = 88;
463 rect.p1.x = 160;
464 rect.p1.y = 101;
465 }
466
467 ui_label_set_rect(demo.label, &rect);
468 ui_label_set_halign(demo.label, gfx_halign_center);
469
470 rc = ui_fixed_add(demo.fixed, ui_label_ctl(demo.label));
471 if (rc != EOK) {
472 printf("Error adding control to layout.\n");
473 return rc;
474 }
475
476 rc = ui_pbutton_create(ui_res, "OK", &demo.pb1);
477 if (rc != EOK) {
478 printf("Error creating button.\n");
479 return rc;
480 }
481
482 ui_pbutton_set_cb(demo.pb1, &pbutton_cb, (void *) &demo);
483
484 /* FIXME: Auto layout */
485 if (ui_is_textmode(ui)) {
486 rect.p0.x = 20;
487 rect.p0.y = 8;
488 rect.p1.x = 30;
489 rect.p1.y = 9;
490 } else {
491 rect.p0.x = 15;
492 rect.p0.y = 111;
493 rect.p1.x = 105;
494 rect.p1.y = 139;
495 }
496
497 ui_pbutton_set_rect(demo.pb1, &rect);
498
499 ui_pbutton_set_default(demo.pb1, true);
500
501 rc = ui_fixed_add(demo.fixed, ui_pbutton_ctl(demo.pb1));
502 if (rc != EOK) {
503 printf("Error adding control to layout.\n");
504 return rc;
505 }
506
507 rc = ui_pbutton_create(ui_res, "Cancel", &demo.pb2);
508 if (rc != EOK) {
509 printf("Error creating button.\n");
510 return rc;
511 }
512
513 ui_pbutton_set_cb(demo.pb2, &pbutton_cb, (void *) &demo);
514
515 if (ui_is_textmode(ui)) {
516 rect.p0.x = 50;
517 rect.p0.y = 8;
518 rect.p1.x = 60;
519 rect.p1.y = 9;
520 } else {
521 rect.p0.x = 115;
522 rect.p0.y = 111;
523 rect.p1.x = 205;
524 rect.p1.y = 139;
525 }
526
527 ui_pbutton_set_rect(demo.pb2, &rect);
528
529 rc = ui_fixed_add(demo.fixed, ui_pbutton_ctl(demo.pb2));
530 if (rc != EOK) {
531 printf("Error adding control to layout.\n");
532 return rc;
533 }
534
535 gfx_bitmap_params_init(&bparams);
536 bparams.rect.p0.x = 0;
537 bparams.rect.p0.y = 0;
538 bparams.rect.p1.x = 188;
539 bparams.rect.p1.y = 24;
540
541 rc = gfx_bitmap_create(gc, &bparams, NULL, &bitmap);
542 if (rc != EOK)
543 return rc;
544
545 rc = bitmap_moire(bitmap, bparams.rect.p1.x, bparams.rect.p1.y);
546 if (rc != EOK)
547 return rc;
548
549 rc = ui_image_create(ui_res, bitmap, &params.rect, &demo.image);
550 if (rc != EOK) {
551 printf("Error creating label.\n");
552 return rc;
553 }
554
555 off.x = 15;
556 off.y = 155;
557 gfx_rect_translate(&off, &bparams.rect, &rect);
558
559 /* Adjust for frame width (2 x 1 pixel) */
560 rect.p1.x += 2;
561 rect.p1.y += 2;
562 ui_image_set_rect(demo.image, &rect);
563 ui_image_set_flags(demo.image, ui_imgf_frame);
564
565 rc = ui_fixed_add(demo.fixed, ui_image_ctl(demo.image));
566 if (rc != EOK) {
567 printf("Error adding control to layout.\n");
568 return rc;
569 }
570
571 rc = ui_checkbox_create(ui_res, "Read only", &demo.checkbox);
572 if (rc != EOK) {
573 printf("Error creating check box.\n");
574 return rc;
575 }
576
577 ui_checkbox_set_cb(demo.checkbox, &checkbox_cb, (void *) &demo);
578
579 rect.p0.x = 15;
580 rect.p0.y = 190;
581 rect.p1.x = 140;
582 rect.p1.y = 210;
583 ui_checkbox_set_rect(demo.checkbox, &rect);
584
585 rc = ui_fixed_add(demo.fixed, ui_checkbox_ctl(demo.checkbox));
586 if (rc != EOK) {
587 printf("Error adding control to layout.\n");
588 return rc;
589 }
590
591 rc = ui_rbutton_group_create(ui_res, &demo.rbgroup);
592 if (rc != EOK) {
593 printf("Error creating radio button group.\n");
594 return rc;
595 }
596
597 rc = ui_rbutton_create(demo.rbgroup, "Left", (void *) &uidemo_halign[0],
598 &demo.rbleft);
599 if (rc != EOK) {
600 printf("Error creating radio button.\n");
601 return rc;
602 }
603
604 ui_rbutton_group_set_cb(demo.rbgroup, &rbutton_group_cb,
605 (void *) &demo);
606
607 rect.p0.x = 15;
608 rect.p0.y = 220;
609 rect.p1.x = 140;
610 rect.p1.y = 240;
611 ui_rbutton_set_rect(demo.rbleft, &rect);
612
613 rc = ui_fixed_add(demo.fixed, ui_rbutton_ctl(demo.rbleft));
614 if (rc != EOK) {
615 printf("Error adding control to layout.\n");
616 return rc;
617 }
618
619 rc = ui_rbutton_create(demo.rbgroup, "Center", (void *) &uidemo_halign[1],
620 &demo.rbcenter);
621 if (rc != EOK) {
622 printf("Error creating radio button.\n");
623 return rc;
624 }
625
626 rect.p0.x = 15;
627 rect.p0.y = 250;
628 rect.p1.x = 140;
629 rect.p1.y = 270;
630 ui_rbutton_set_rect(demo.rbcenter, &rect);
631 ui_rbutton_select(demo.rbcenter);
632
633 rc = ui_fixed_add(demo.fixed, ui_rbutton_ctl(demo.rbcenter));
634 if (rc != EOK) {
635 printf("Error adding control to layout.\n");
636 return rc;
637 }
638
639 rc = ui_rbutton_create(demo.rbgroup, "Right", (void *) &uidemo_halign[2],
640 &demo.rbright);
641 if (rc != EOK) {
642 printf("Error creating radio button.\n");
643 return rc;
644 }
645
646 rect.p0.x = 15;
647 rect.p0.y = 280;
648 rect.p1.x = 140;
649 rect.p1.y = 300;
650 ui_rbutton_set_rect(demo.rbright, &rect);
651
652 rc = ui_fixed_add(demo.fixed, ui_rbutton_ctl(demo.rbright));
653 if (rc != EOK) {
654 printf("Error adding control to layout.\n");
655 return rc;
656 }
657
658 rc = ui_slider_create(ui_res, "Slide!", &demo.slider);
659 if (rc != EOK) {
660 printf("Error creating button.\n");
661 return rc;
662 }
663
664 ui_slider_set_cb(demo.slider, &slider_cb, (void *) &demo);
665
666 rect.p0.x = 15;
667 rect.p0.y = 310;
668 rect.p1.x = 130;
669 rect.p1.y = 330;
670 ui_slider_set_rect(demo.slider, &rect);
671
672 rc = ui_fixed_add(demo.fixed, ui_slider_ctl(demo.slider));
673 if (rc != EOK) {
674 printf("Error adding control to layout.\n");
675 return rc;
676 }
677
678 ui_window_add(window, ui_fixed_ctl(demo.fixed));
679
680 rc = ui_window_paint(window);
681 if (rc != EOK) {
682 printf("Error painting window.\n");
683 return rc;
684 }
685
686 ui_run(ui);
687
688 ui_window_destroy(window);
689 ui_destroy(ui);
690
691 return EOK;
692}
693
694/** Fill bitmap with moire pattern.
695 *
696 * @param bitmap Bitmap
697 * @param w Bitmap width
698 * @param h Bitmap height
699 * @return EOK on success or an error code
700 */
701static errno_t bitmap_moire(gfx_bitmap_t *bitmap, gfx_coord_t w, gfx_coord_t h)
702{
703 int i, j;
704 int k;
705 pixelmap_t pixelmap;
706 gfx_bitmap_alloc_t alloc;
707 errno_t rc;
708
709 rc = gfx_bitmap_get_alloc(bitmap, &alloc);
710 if (rc != EOK)
711 return rc;
712
713 /* In absence of anything else, use pixelmap */
714 pixelmap.width = w;
715 pixelmap.height = h;
716 pixelmap.data = alloc.pixels;
717
718 for (i = 0; i < w; i++) {
719 for (j = 0; j < h; j++) {
720 k = i * i + j * j;
721 pixelmap_put_pixel(&pixelmap, i, j,
722 PIXEL(255, k, k, 255 - k));
723 }
724 }
725
726 return EOK;
727}
728
729static void print_syntax(void)
730{
731 printf("Syntax: uidemo [-d <display-spec>]\n");
732}
733
734int main(int argc, char *argv[])
735{
736 const char *display_spec = UI_DISPLAY_DEFAULT;
737 errno_t rc;
738 int i;
739
740 i = 1;
741 while (i < argc && argv[i][0] == '-') {
742 if (str_cmp(argv[i], "-d") == 0) {
743 ++i;
744 if (i >= argc) {
745 printf("Argument missing.\n");
746 print_syntax();
747 return 1;
748 }
749
750 display_spec = argv[i++];
751 } else {
752 printf("Invalid option '%s'.\n", argv[i]);
753 print_syntax();
754 return 1;
755 }
756 }
757
758 if (i < argc) {
759 print_syntax();
760 return 1;
761 }
762
763 rc = ui_demo(display_spec);
764 if (rc != EOK)
765 return 1;
766
767 return 0;
768}
769
770/** @}
771 */
Note: See TracBrowser for help on using the repository browser.