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

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

Make more of UI demo visible in text mode

So that we can test text entry.

  • Property mode set to 100644
File size: 16.9 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/** Window close button was clicked.
99 *
100 * @param window Window
101 * @param arg Argument (demo)
102 */
103static void wnd_close(ui_window_t *window, void *arg)
104{
105 ui_demo_t *demo = (ui_demo_t *) arg;
106
107 ui_quit(demo->ui);
108}
109
110/** Push button was clicked.
111 *
112 * @param pbutton Push button
113 * @param arg Argument (demo)
114 */
115static void pb_clicked(ui_pbutton_t *pbutton, void *arg)
116{
117 ui_demo_t *demo = (ui_demo_t *) arg;
118 errno_t rc;
119
120 if (pbutton == demo->pb1) {
121 rc = ui_entry_set_text(demo->entry, "OK pressed");
122 if (rc != EOK)
123 printf("Error changing entry text.\n");
124 (void) ui_entry_paint(demo->entry);
125 } else {
126 rc = ui_entry_set_text(demo->entry, "Cancel pressed");
127 if (rc != EOK)
128 printf("Error changing entry text.\n");
129 (void) ui_entry_paint(demo->entry);
130 }
131}
132
133/** Check box was switched.
134 *
135 * @param checkbox Check box
136 * @param arg Argument (demo)
137 */
138static void checkbox_switched(ui_checkbox_t *checkbox, void *arg, bool enable)
139{
140 ui_demo_t *demo = (ui_demo_t *) arg;
141 errno_t rc;
142
143 if (enable) {
144 rc = ui_entry_set_text(demo->entry, "Checked");
145 if (rc != EOK)
146 printf("Error changing entry text.\n");
147 (void) ui_entry_paint(demo->entry);
148 } else {
149 rc = ui_entry_set_text(demo->entry, "Unchecked");
150 if (rc != EOK)
151 printf("Error changing entry text.\n");
152 (void) ui_entry_paint(demo->entry);
153 }
154}
155
156/** Radio button was selected.
157 *
158 * @param rbgroup Radio button group
159 * @param garg Group argument (demo)
160 * @param barg Button argument
161 */
162static void rb_selected(ui_rbutton_group_t *rbgroup, void *garg, void *barg)
163{
164 ui_demo_t *demo = (ui_demo_t *) garg;
165 const char *text = (const char *) barg;
166 errno_t rc;
167
168 rc = ui_entry_set_text(demo->entry, text);
169 if (rc != EOK)
170 printf("Error changing entry text.\n");
171 (void) ui_entry_paint(demo->entry);
172}
173
174/** Slider was moved.
175 *
176 * @param slider Slider
177 * @param arg Argument (demo)
178 * @param pos Position
179 */
180static void slider_moved(ui_slider_t *slider, void *arg, gfx_coord_t pos)
181{
182 ui_demo_t *demo = (ui_demo_t *) arg;
183 char *str;
184 errno_t rc;
185 int rv;
186
187 rv = asprintf(&str, "Slider at %d of %d", (int) pos,
188 ui_slider_length(slider));
189 if (rv < 0) {
190 printf("Out of memory.\n");
191 return;
192 }
193
194 rc = ui_entry_set_text(demo->entry, str);
195 if (rc != EOK)
196 printf("Error changing entry text.\n");
197 (void) ui_entry_paint(demo->entry);
198
199 free(str);
200}
201
202/** File/message menu entry selected.
203 *
204 * @param mentry Menu entry
205 * @param arg Argument (demo)
206 */
207static void uidemo_file_message(ui_menu_entry_t *mentry, void *arg)
208{
209 ui_demo_t *demo = (ui_demo_t *) arg;
210 ui_msg_dialog_params_t mdparams;
211 ui_msg_dialog_t *dialog;
212 errno_t rc;
213
214 ui_msg_dialog_params_init(&mdparams);
215 mdparams.caption = "Message For You";
216 mdparams.text = "Hello, world!";
217
218 rc = ui_msg_dialog_create(demo->ui, &mdparams, &dialog);
219 if (rc != EOK) {
220 printf("Error creating message dialog.\n");
221 return;
222 }
223
224 ui_msg_dialog_set_cb(dialog, &msg_dialog_cb, &demo);
225
226}
227
228/** File/exit menu entry selected.
229 *
230 * @param mentry Menu entry
231 * @param arg Argument (demo)
232 */
233static void uidemo_file_exit(ui_menu_entry_t *mentry, void *arg)
234{
235 ui_demo_t *demo = (ui_demo_t *) arg;
236
237 ui_quit(demo->ui);
238}
239
240/** Message dialog button press.
241 *
242 * @param dialog Message dialog
243 * @param arg Argument (ui_demo_t *)
244 * @param bnum Button number
245 */
246static void msg_dialog_button(ui_msg_dialog_t *dialog, void *arg,
247 unsigned bnum)
248{
249 ui_demo_t *demo = (ui_demo_t *) arg;
250
251 (void) demo;
252 ui_msg_dialog_destroy(dialog);
253}
254
255/** Message dialog close request.
256 *
257 * @param dialog Message dialog
258 * @param arg Argument (ui_demo_t *)
259 */
260static void msg_dialog_close(ui_msg_dialog_t *dialog, void *arg)
261{
262 ui_demo_t *demo = (ui_demo_t *) arg;
263
264 (void) demo;
265 ui_msg_dialog_destroy(dialog);
266}
267
268/** Run UI demo on display server. */
269static errno_t ui_demo(const char *display_spec)
270{
271 ui_t *ui = NULL;
272 ui_wnd_params_t params;
273 ui_window_t *window = NULL;
274 ui_demo_t demo;
275 gfx_rect_t rect;
276 gfx_context_t *gc;
277 ui_resource_t *ui_res;
278 gfx_bitmap_params_t bparams;
279 gfx_bitmap_t *bitmap;
280 gfx_coord2_t off;
281 ui_menu_entry_t *mmsg;
282 ui_menu_entry_t *mfoo;
283 ui_menu_entry_t *mbar;
284 ui_menu_entry_t *mfoobar;
285 ui_menu_entry_t *mexit;
286 ui_menu_entry_t *mabout;
287 errno_t rc;
288
289 rc = ui_create(display_spec, &ui);
290 if (rc != EOK) {
291 printf("Error creating UI on display %s.\n", display_spec);
292 return rc;
293 }
294
295 memset((void *) &demo, 0, sizeof(demo));
296 demo.ui = ui;
297
298 ui_wnd_params_init(&params);
299 params.caption = "UI Demo";
300 params.style |= ui_wds_resizable;
301
302 /* FIXME: Auto layout */
303 if (ui_is_textmode(ui)) {
304 params.rect.p0.x = 0;
305 params.rect.p0.y = 0;
306 params.rect.p1.x = 80;
307 params.rect.p1.y = 25;
308 } else {
309 params.rect.p0.x = 0;
310 params.rect.p0.y = 0;
311 params.rect.p1.x = 220;
312 params.rect.p1.y = 350;
313 }
314
315 rc = ui_window_create(ui, &params, &window);
316 if (rc != EOK) {
317 printf("Error creating window.\n");
318 return rc;
319 }
320
321 ui_window_set_cb(window, &window_cb, (void *) &demo);
322 demo.window = window;
323
324 ui_res = ui_window_get_res(window);
325 gc = ui_window_get_gc(window);
326
327 rc = ui_fixed_create(&demo.fixed);
328 if (rc != EOK) {
329 printf("Error creating fixed layout.\n");
330 return rc;
331 }
332
333 rc = ui_menu_bar_create(ui, window, &demo.mbar);
334 if (rc != EOK) {
335 printf("Error creating menu bar.\n");
336 return rc;
337 }
338
339 rc = ui_menu_create(demo.mbar, "File", &demo.mfile);
340 if (rc != EOK) {
341 printf("Error creating menu.\n");
342 return rc;
343 }
344
345 rc = ui_menu_entry_create(demo.mfile, "Message", "", &mmsg);
346 if (rc != EOK) {
347 printf("Error creating menu.\n");
348 return rc;
349 }
350
351 ui_menu_entry_set_cb(mmsg, uidemo_file_message, (void *) &demo);
352
353 rc = ui_menu_entry_create(demo.mfile, "Foo", "Ctrl-Alt-Del", &mfoo);
354 if (rc != EOK) {
355 printf("Error creating menu.\n");
356 return rc;
357 }
358
359 rc = ui_menu_entry_create(demo.mfile, "Bar", "", &mbar);
360 if (rc != EOK) {
361 printf("Error creating menu.\n");
362 return rc;
363 }
364
365 rc = ui_menu_entry_create(demo.mfile, "Foobar", "", &mfoobar);
366 if (rc != EOK) {
367 printf("Error creating menu.\n");
368 return rc;
369 }
370
371 rc = ui_menu_entry_sep_create(demo.mfile, &mexit);
372 if (rc != EOK) {
373 printf("Error creating menu.\n");
374 return rc;
375 }
376
377 rc = ui_menu_entry_create(demo.mfile, "Exit", "Alt-F4", &mexit);
378 if (rc != EOK) {
379 printf("Error creating menu.\n");
380 return rc;
381 }
382
383 ui_menu_entry_set_cb(mexit, uidemo_file_exit, (void *) &demo);
384
385 rc = ui_menu_create(demo.mbar, "Edit", &demo.medit);
386 if (rc != EOK) {
387 printf("Error creating menu.\n");
388 return rc;
389 }
390
391 rc = ui_menu_create(demo.mbar, "Preferences", &demo.mpreferences);
392 if (rc != EOK) {
393 printf("Error creating menu.\n");
394 return rc;
395 }
396
397 rc = ui_menu_create(demo.mbar, "Help", &demo.mhelp);
398 if (rc != EOK) {
399 printf("Error creating menu.\n");
400 return rc;
401 }
402
403 rc = ui_menu_entry_create(demo.mhelp, "About", "Ctrl-H, F1", &mabout);
404 if (rc != EOK) {
405 printf("Error creating menu.\n");
406 return rc;
407 }
408
409 /* FIXME: Auto layout */
410 if (ui_is_textmode(ui)) {
411 rect.p0.x = 1;
412 rect.p0.y = 2;
413 rect.p1.x = 79;
414 rect.p1.y = 3;
415 } else {
416 rect.p0.x = 4;
417 rect.p0.y = 30;
418 rect.p1.x = 216;
419 rect.p1.y = 52;
420 }
421 ui_menu_bar_set_rect(demo.mbar, &rect);
422
423 rc = ui_fixed_add(demo.fixed, ui_menu_bar_ctl(demo.mbar));
424 if (rc != EOK) {
425 printf("Error adding control to layout.\n");
426 return rc;
427 }
428
429 rc = ui_entry_create(window, "", &demo.entry);
430 if (rc != EOK) {
431 printf("Error creating entry.\n");
432 return rc;
433 }
434
435 /* FIXME: Auto layout */
436 if (ui_is_textmode(ui)) {
437 rect.p0.x = 20;
438 rect.p0.y = 4;
439 rect.p1.x = 60;
440 rect.p1.y = 5;
441 } else {
442 rect.p0.x = 15;
443 rect.p0.y = 53;
444 rect.p1.x = 205;
445 rect.p1.y = 78;
446 }
447
448 ui_entry_set_rect(demo.entry, &rect);
449 ui_entry_set_halign(demo.entry, gfx_halign_center);
450
451 rc = ui_fixed_add(demo.fixed, ui_entry_ctl(demo.entry));
452 if (rc != EOK) {
453 printf("Error adding control to layout.\n");
454 return rc;
455 }
456
457 rc = ui_label_create(ui_res, "Text label", &demo.label);
458 if (rc != EOK) {
459 printf("Error creating label.\n");
460 return rc;
461 }
462
463 /* FIXME: Auto layout */
464 if (ui_is_textmode(ui)) {
465 rect.p0.x = 20;
466 rect.p0.y = 6;
467 rect.p1.x = 60;
468 rect.p1.y = 7;
469 } else {
470 rect.p0.x = 60;
471 rect.p0.y = 88;
472 rect.p1.x = 160;
473 rect.p1.y = 101;
474 }
475
476 ui_label_set_rect(demo.label, &rect);
477 ui_label_set_halign(demo.label, gfx_halign_center);
478
479 rc = ui_fixed_add(demo.fixed, ui_label_ctl(demo.label));
480 if (rc != EOK) {
481 printf("Error adding control to layout.\n");
482 return rc;
483 }
484
485 rc = ui_pbutton_create(ui_res, "OK", &demo.pb1);
486 if (rc != EOK) {
487 printf("Error creating button.\n");
488 return rc;
489 }
490
491 ui_pbutton_set_cb(demo.pb1, &pbutton_cb, (void *) &demo);
492
493 /* FIXME: Auto layout */
494 if (ui_is_textmode(ui)) {
495 rect.p0.x = 20;
496 rect.p0.y = 8;
497 rect.p1.x = 30;
498 rect.p1.y = 9;
499 } else {
500 rect.p0.x = 15;
501 rect.p0.y = 111;
502 rect.p1.x = 105;
503 rect.p1.y = 139;
504 }
505
506 ui_pbutton_set_rect(demo.pb1, &rect);
507
508 ui_pbutton_set_default(demo.pb1, true);
509
510 rc = ui_fixed_add(demo.fixed, ui_pbutton_ctl(demo.pb1));
511 if (rc != EOK) {
512 printf("Error adding control to layout.\n");
513 return rc;
514 }
515
516 rc = ui_pbutton_create(ui_res, "Cancel", &demo.pb2);
517 if (rc != EOK) {
518 printf("Error creating button.\n");
519 return rc;
520 }
521
522 ui_pbutton_set_cb(demo.pb2, &pbutton_cb, (void *) &demo);
523
524 if (ui_is_textmode(ui)) {
525 rect.p0.x = 50;
526 rect.p0.y = 8;
527 rect.p1.x = 60;
528 rect.p1.y = 9;
529 } else {
530 rect.p0.x = 115;
531 rect.p0.y = 111;
532 rect.p1.x = 205;
533 rect.p1.y = 139;
534 }
535
536 ui_pbutton_set_rect(demo.pb2, &rect);
537
538 rc = ui_fixed_add(demo.fixed, ui_pbutton_ctl(demo.pb2));
539 if (rc != EOK) {
540 printf("Error adding control to layout.\n");
541 return rc;
542 }
543
544 gfx_bitmap_params_init(&bparams);
545 bparams.rect.p0.x = 0;
546 bparams.rect.p0.y = 0;
547 bparams.rect.p1.x = 188;
548 bparams.rect.p1.y = 24;
549
550 rc = gfx_bitmap_create(gc, &bparams, NULL, &bitmap);
551 if (rc != EOK)
552 return rc;
553
554 rc = bitmap_moire(bitmap, bparams.rect.p1.x, bparams.rect.p1.y);
555 if (rc != EOK)
556 return rc;
557
558 rc = ui_image_create(ui_res, bitmap, &params.rect, &demo.image);
559 if (rc != EOK) {
560 printf("Error creating label.\n");
561 return rc;
562 }
563
564 off.x = 15;
565 off.y = 155;
566 gfx_rect_translate(&off, &bparams.rect, &rect);
567
568 /* Adjust for frame width (2 x 1 pixel) */
569 rect.p1.x += 2;
570 rect.p1.y += 2;
571 ui_image_set_rect(demo.image, &rect);
572 ui_image_set_flags(demo.image, ui_imgf_frame);
573
574 rc = ui_fixed_add(demo.fixed, ui_image_ctl(demo.image));
575 if (rc != EOK) {
576 printf("Error adding control to layout.\n");
577 return rc;
578 }
579
580 rc = ui_checkbox_create(ui_res, "Check me", &demo.checkbox);
581 if (rc != EOK) {
582 printf("Error creating check box.\n");
583 return rc;
584 }
585
586 ui_checkbox_set_cb(demo.checkbox, &checkbox_cb, (void *) &demo);
587
588 rect.p0.x = 15;
589 rect.p0.y = 190;
590 rect.p1.x = 140;
591 rect.p1.y = 210;
592 ui_checkbox_set_rect(demo.checkbox, &rect);
593
594 rc = ui_fixed_add(demo.fixed, ui_checkbox_ctl(demo.checkbox));
595 if (rc != EOK) {
596 printf("Error adding control to layout.\n");
597 return rc;
598 }
599
600 rc = ui_rbutton_group_create(ui_res, &demo.rbgroup);
601 if (rc != EOK) {
602 printf("Error creating radio button group.\n");
603 return rc;
604 }
605
606 rc = ui_rbutton_create(demo.rbgroup, "Option 1", (void *) "First",
607 &demo.rb1);
608 if (rc != EOK) {
609 printf("Error creating radio button.\n");
610 return rc;
611 }
612
613 ui_rbutton_group_set_cb(demo.rbgroup, &rbutton_group_cb,
614 (void *) &demo);
615
616 rect.p0.x = 15;
617 rect.p0.y = 220;
618 rect.p1.x = 140;
619 rect.p1.y = 240;
620 ui_rbutton_set_rect(demo.rb1, &rect);
621
622 rc = ui_fixed_add(demo.fixed, ui_rbutton_ctl(demo.rb1));
623 if (rc != EOK) {
624 printf("Error adding control to layout.\n");
625 return rc;
626 }
627
628 rc = ui_rbutton_create(demo.rbgroup, "Option 2", (void *) "Second",
629 &demo.rb2);
630 if (rc != EOK) {
631 printf("Error creating radio button.\n");
632 return rc;
633 }
634
635 rect.p0.x = 15;
636 rect.p0.y = 250;
637 rect.p1.x = 140;
638 rect.p1.y = 270;
639 ui_rbutton_set_rect(demo.rb2, &rect);
640
641 rc = ui_fixed_add(demo.fixed, ui_rbutton_ctl(demo.rb2));
642 if (rc != EOK) {
643 printf("Error adding control to layout.\n");
644 return rc;
645 }
646
647 rc = ui_rbutton_create(demo.rbgroup, "Option 3", (void *) "Third",
648 &demo.rb3);
649 if (rc != EOK) {
650 printf("Error creating radio button.\n");
651 return rc;
652 }
653
654 rect.p0.x = 15;
655 rect.p0.y = 280;
656 rect.p1.x = 140;
657 rect.p1.y = 300;
658 ui_rbutton_set_rect(demo.rb3, &rect);
659
660 rc = ui_fixed_add(demo.fixed, ui_rbutton_ctl(demo.rb3));
661 if (rc != EOK) {
662 printf("Error adding control to layout.\n");
663 return rc;
664 }
665
666 rc = ui_slider_create(ui_res, "Slide!", &demo.slider);
667 if (rc != EOK) {
668 printf("Error creating button.\n");
669 return rc;
670 }
671
672 ui_slider_set_cb(demo.slider, &slider_cb, (void *) &demo);
673
674 rect.p0.x = 15;
675 rect.p0.y = 310;
676 rect.p1.x = 130;
677 rect.p1.y = 330;
678 ui_slider_set_rect(demo.slider, &rect);
679
680 rc = ui_fixed_add(demo.fixed, ui_slider_ctl(demo.slider));
681 if (rc != EOK) {
682 printf("Error adding control to layout.\n");
683 return rc;
684 }
685
686 ui_window_add(window, ui_fixed_ctl(demo.fixed));
687
688 rc = ui_window_paint(window);
689 if (rc != EOK) {
690 printf("Error painting window.\n");
691 return rc;
692 }
693
694 ui_run(ui);
695
696 ui_window_destroy(window);
697 ui_destroy(ui);
698
699 return EOK;
700}
701
702/** Fill bitmap with moire pattern.
703 *
704 * @param bitmap Bitmap
705 * @param w Bitmap width
706 * @param h Bitmap height
707 * @return EOK on success or an error code
708 */
709static errno_t bitmap_moire(gfx_bitmap_t *bitmap, gfx_coord_t w, gfx_coord_t h)
710{
711 int i, j;
712 int k;
713 pixelmap_t pixelmap;
714 gfx_bitmap_alloc_t alloc;
715 errno_t rc;
716
717 rc = gfx_bitmap_get_alloc(bitmap, &alloc);
718 if (rc != EOK)
719 return rc;
720
721 /* In absence of anything else, use pixelmap */
722 pixelmap.width = w;
723 pixelmap.height = h;
724 pixelmap.data = alloc.pixels;
725
726 for (i = 0; i < w; i++) {
727 for (j = 0; j < h; j++) {
728 k = i * i + j * j;
729 pixelmap_put_pixel(&pixelmap, i, j,
730 PIXEL(255, k, k, 255 - k));
731 }
732 }
733
734 return EOK;
735}
736
737static void print_syntax(void)
738{
739 printf("Syntax: uidemo [-d <display-spec>]\n");
740}
741
742int main(int argc, char *argv[])
743{
744 const char *display_spec = UI_DISPLAY_DEFAULT;
745 errno_t rc;
746 int i;
747
748 i = 1;
749 while (i < argc && argv[i][0] == '-') {
750 if (str_cmp(argv[i], "-d") == 0) {
751 ++i;
752 if (i >= argc) {
753 printf("Argument missing.\n");
754 print_syntax();
755 return 1;
756 }
757
758 display_spec = argv[i++];
759 } else {
760 printf("Invalid option '%s'.\n", argv[i]);
761 print_syntax();
762 return 1;
763 }
764 }
765
766 if (i < argc) {
767 print_syntax();
768 return 1;
769 }
770
771 rc = ui_demo(display_spec);
772 if (rc != EOK)
773 return 1;
774
775 return 0;
776}
777
778/** @}
779 */
Note: See TracBrowser for help on using the repository browser.