source: mainline/uspace/app/vterm/vterm.c@ f80690a

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

Make display service argument optional

  • Property mode set to 100644
File size: 2.7 KB
Line 
1/*
2 * Copyright (c) 2020 Jiri Svoboda
3 * Copyright (c) 2012 Petr Koupy
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * - Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * - Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * - The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30/** @addtogroup vterm
31 * @{
32 */
33/** @file
34 */
35
36#include <stdbool.h>
37#include <stdio.h>
38#include <io/pixel.h>
39#include <task.h>
40#include <window.h>
41#include <terminal.h>
42
43#define NAME "vterm"
44
45static void print_syntax(void)
46{
47 printf("Syntax: %s [-d <display>]\n", NAME);
48}
49
50int main(int argc, char *argv[])
51{
52 const char *display_svc = DISPLAY_DEFAULT;
53 int i;
54
55 i = 1;
56 while (i < argc) {
57 if (str_cmp(argv[i], "-d") == 0) {
58 ++i;
59 if (i >= argc) {
60 printf("Argument missing.\n");
61 print_syntax();
62 return 1;
63 }
64
65 display_svc = argv[i++];
66 } else {
67 printf("Invalid option '%s'.\n", argv[i]);
68 print_syntax();
69 return 1;
70 }
71 }
72
73 window_t *main_window = window_open(display_svc, NULL,
74 WINDOW_MAIN | WINDOW_DECORATED, "vterm");
75 if (!main_window) {
76 printf("%s: Cannot open main window.\n", NAME);
77 return 2;
78 }
79
80 window_resize(main_window, 0, 0, 648, 508, WINDOW_PLACEMENT_TOP |
81 WINDOW_PLACEMENT_LEFT);
82 terminal_t *terminal_widget =
83 create_terminal(window_root(main_window), NULL, 640, 480);
84 if (!terminal_widget) {
85 window_close(main_window);
86 printf("%s: Cannot create widgets.\n", NAME);
87 return 3;
88 }
89
90 window_exec(main_window);
91 task_retval(0);
92 async_manager();
93
94 return 0;
95}
96
97/** @}
98 */
Note: See TracBrowser for help on using the repository browser.