Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bdsh/cmds/modules/cat/cat.c

    r28a3e74 r36ab7c7  
    1 /* Copyright (c) 2008, Tim Post <tinkertim@gmail.com>
     1/*
     2 * Copyright (c) 2008 Tim Post
    23 * Copyright (c) 2011, Martin Sucha
    34 * All rights reserved.
    45 *
    56 * Redistribution and use in source and binary forms, with or without
    6  * modification, are permitted provided that the following conditions are met:
     7 * modification, are permitted provided that the following conditions
     8 * are met:
    79 *
    8  * Redistributions of source code must retain the above copyright notice, this
    9  * list of conditions and the following disclaimer.
     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.
    1017 *
    11  * Redistributions in binary form must reproduce the above copyright notice,
    12  * this list of conditions and the following disclaimer in the documentation
    13  * and/or other materials provided with the distribution.
    14  *
    15  * Neither the name of the original program's authors nor the names of its
    16  * contributors may be used to endorse or promote products derived from this
    17  * software without specific prior written permission.
    18  *
    19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
    23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    29  * POSSIBILITY OF SUCH DAMAGE.
     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.
    3028 */
    3129
     
    6462static sysarg_t console_rows = 0;
    6563static bool should_quit = false;
     64
     65static console_ctrl_t *console = NULL;
    6666
    6767static struct option const long_options[] = {
     
    102102static void waitprompt()
    103103{
    104         console_set_pos(fphone(stdout), 0, console_rows-1);
    105         console_set_color(fphone(stdout), COLOR_BLUE, COLOR_WHITE, 0);
     104        console_set_pos(console, 0, console_rows-1);
     105        console_set_color(console, COLOR_BLUE, COLOR_WHITE, 0);
     106       
    106107        printf("ENTER/SPACE/PAGE DOWN - next page, "
    107108               "ESC/Q - quit, C - continue unpaged");
    108109        fflush(stdout);
    109         console_set_style(fphone(stdout), STYLE_NORMAL);
     110       
     111        console_set_style(console, STYLE_NORMAL);
    110112}
    111113
    112114static void waitkey()
    113115{
    114         console_event_t ev;
     116        kbd_event_t ev;
    115117       
    116118        while (true) {
    117                 if (!console_get_event(fphone(stdin), &ev)) {
     119                if (!console_get_kbd_event(console, &ev)) {
    118120                        return;
    119121                }
     
    138140static void newpage()
    139141{
    140         console_clear(fphone(stdout));
     142        console_clear(console);
    141143        chars_remaining = console_cols;
    142         lines_remaining = console_rows-1;
     144        lines_remaining = console_rows - 1;
    143145}
    144146
     
    238240        console_rows = 0;
    239241        should_quit = false;
     242        console = console_init(stdin, stdout);
    240243
    241244        argc = cli_count_args(argv);
     
    280283       
    281284        if (more) {
    282                 rc = console_get_size(fphone(stdout), &cols, &rows);
     285                rc = console_get_size(console, &cols, &rows);
    283286                if (rc != EOK) {
    284287                        printf("%s - cannot get console size\n", cmdname);
Note: See TracChangeset for help on using the changeset viewer.