Changeset 7e38970d in mainline for uspace/app/terminal/main.c


Ignore:
Timestamp:
2020-12-07T00:08:37Z (4 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
25f26600
Parents:
7a873f0 (diff), 8596474 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'jxsvoboda-gfx' into master

File:
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/app/terminal/main.c

    r7a873f0 r7e38970d  
    11/*
    22 * Copyright (c) 2020 Jiri Svoboda
    3  * Copyright (c) 2012 Petr Koupy
    43 * All rights reserved.
    54 *
     
    2827 */
    2928
    30 /** @addtogroup vterm
     29/** @addtogroup terminal
    3130 * @{
    3231 */
     
    3433 */
    3534
    36 #include <stdbool.h>
    3735#include <stdio.h>
    38 #include <io/pixel.h>
    3936#include <task.h>
    40 #include <window.h>
    41 #include <terminal.h>
     37#include <ui/ui.h>
     38#include "terminal.h"
    4239
    43 #define NAME  "vterm"
     40#define NAME  "terminal"
    4441
     42/** Print syntax. */
    4543static void print_syntax(void)
    4644{
    47         printf("Syntax: %s [-d <display>]\n", NAME);
     45        printf("Syntax: %s [<options>]\n", NAME);
     46        printf("\t-d <display-spec> Use the specified display\n");
     47        printf("\t-topleft]         Place window to the top-left corner of "
     48            "the screen\n");
    4849}
    4950
    5051int main(int argc, char *argv[])
    5152{
    52         const char *display_svc = DISPLAY_DEFAULT;
     53        const char *display_spec = UI_DISPLAY_DEFAULT;
     54        terminal_t *terminal = NULL;
     55        terminal_flags_t flags = 0;
     56        errno_t rc;
    5357        int i;
    5458
    5559        i = 1;
    56         while (i < argc) {
     60        while (i < argc && argv[i][0] == '-') {
    5761                if (str_cmp(argv[i], "-d") == 0) {
    5862                        ++i;
     
    6367                        }
    6468
    65                         display_svc = argv[i++];
     69                        display_spec = argv[i++];
     70                } else if (str_cmp(argv[i], "-topleft") == 0) {
     71                        ++i;
     72                        flags |= tf_topleft;
    6673                } else {
    6774                        printf("Invalid option '%s'.\n", argv[i]);
     
    7178        }
    7279
    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;
     80        if (i < argc) {
     81                print_syntax();
     82                return 1;
    7883        }
    7984
    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         }
     85        rc = terminal_create(display_spec, 640, 480, flags, &terminal);
     86        if (rc != EOK)
     87                return 1;
    8988
    90         window_exec(main_window);
    9189        task_retval(0);
    9290        async_manager();
    93 
    9491        return 0;
    9592}
Note: See TracChangeset for help on using the changeset viewer.