Changeset 8565a42 in mainline for uspace/lib/gui/terminal.c


Ignore:
Timestamp:
2018-03-02T20:34:50Z (7 years ago)
Author:
GitHub <noreply@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a1a81f69, d5e5fd1
Parents:
3061bc1 (diff), 34e1206 (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.
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:34:50)
git-committer:
GitHub <noreply@…> (2018-03-02 20:34:50)
Message:

Remove all trailing whitespace, everywhere.

See individual commit messages for details.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/gui/terminal.c

    r3061bc1 r8565a42  
    118118        [COLOR_YELLOW]      = PIXEL(255, 240, 240, 0),
    119119        [COLOR_WHITE]       = PIXEL(255, 240, 240, 240),
    120        
     120
    121121        [COLOR_BLACK + 8]   = PIXEL(255, 0, 0, 0),
    122122        [COLOR_BLUE + 8]    = PIXEL(255, 0, 0, 255),
     
    170170        charfield_t *field =
    171171            chargrid_charfield_at(term->backbuf, col, row);
    172        
     172
    173173        bool inverted = chargrid_cursor_at(term->backbuf, col, row);
    174        
     174
    175175        sysarg_t bx = sx + (col * FONT_WIDTH);
    176176        sysarg_t by = sy + (row * FONT_SCANLINES);
    177        
     177
    178178        pixel_t bgcolor = 0;
    179179        pixel_t fgcolor = 0;
    180        
     180
    181181        if (inverted)
    182182                attrs_rgb(field->attrs, &fgcolor, &bgcolor);
    183183        else
    184184                attrs_rgb(field->attrs, &bgcolor, &fgcolor);
    185        
     185
    186186        // FIXME: Glyph type should be actually uint32_t
    187187        //        for full UTF-32 coverage.
    188        
     188
    189189        uint16_t glyph = fb_font_glyph(field->ch, NULL);
    190        
     190
    191191        for (unsigned int y = 0; y < FONT_SCANLINES; y++) {
    192192                pixel_t *dst = pixelmap_pixel_at(
     
    207207{
    208208        sysarg_t top_row = chargrid_get_top_row(term->frontbuf);
    209        
     209
    210210        if (term->top_row == top_row)
    211211                return false;
    212        
     212
    213213        term->top_row = top_row;
    214        
     214
    215215        for (sysarg_t row = 0; row < term->rows; row++) {
    216216                for (sysarg_t col = 0; col < term->cols; col++) {
     
    220220                            chargrid_charfield_at(term->backbuf, col, row);
    221221                        bool update = false;
    222                        
     222
    223223                        if (front_field->ch != back_field->ch) {
    224224                                back_field->ch = front_field->ch;
    225225                                update = true;
    226226                        }
    227                        
     227
    228228                        if (!attrs_same(front_field->attrs, back_field->attrs)) {
    229229                                back_field->attrs = front_field->attrs;
    230230                                update = true;
    231231                        }
    232                        
     232
    233233                        front_field->flags &= ~CHAR_FLAG_DIRTY;
    234                        
     234
    235235                        if (update)
    236236                                term_update_char(term, surface, sx, sy, col, row);
    237237                }
    238238        }
    239        
     239
    240240        return true;
    241241}
     
    245245{
    246246        bool damage = false;
    247        
     247
    248248        sysarg_t front_col;
    249249        sysarg_t front_row;
    250250        chargrid_get_cursor(term->frontbuf, &front_col, &front_row);
    251        
     251
    252252        sysarg_t back_col;
    253253        sysarg_t back_row;
    254254        chargrid_get_cursor(term->backbuf, &back_col, &back_row);
    255        
     255
    256256        bool front_visibility =
    257257            chargrid_get_cursor_visibility(term->frontbuf) &&
     
    259259        bool back_visibility =
    260260            chargrid_get_cursor_visibility(term->backbuf);
    261        
     261
    262262        if (front_visibility != back_visibility) {
    263263                chargrid_set_cursor_visibility(term->backbuf,
     
    266266                damage = true;
    267267        }
    268        
     268
    269269        if ((front_col != back_col) || (front_row != back_row)) {
    270270                chargrid_set_cursor(term->backbuf, front_col, front_row);
     
    273273                damage = true;
    274274        }
    275        
     275
    276276        return damage;
    277277}
     
    280280{
    281281        fibril_mutex_lock(&term->mtx);
    282        
     282
    283283        surface_t *surface = window_claim(term->widget.window);
    284284        if (!surface) {
     
    287287                return;
    288288        }
    289        
     289
    290290        bool damage = false;
    291291        sysarg_t sx = term->widget.hpos;
    292292        sysarg_t sy = term->widget.vpos;
    293        
     293
    294294        if (term_update_scroll(term, surface, sx, sy)) {
    295295                damage = true;
     
    302302                                    chargrid_charfield_at(term->backbuf, x, y);
    303303                                bool update = false;
    304                                
     304
    305305                                if ((front_field->flags & CHAR_FLAG_DIRTY) ==
    306306                                    CHAR_FLAG_DIRTY) {
     
    309309                                                update = true;
    310310                                        }
    311                                        
     311
    312312                                        if (!attrs_same(front_field->attrs,
    313313                                            back_field->attrs)) {
     
    315315                                                update = true;
    316316                                        }
    317                                        
     317
    318318                                        front_field->flags &= ~CHAR_FLAG_DIRTY;
    319319                                }
    320                                
     320
    321321                                if (update) {
    322322                                        term_update_char(term, surface, sx, sy, x, y);
     
    326326                }
    327327        }
    328        
     328
    329329        if (term_update_cursor(term, surface, sx, sy))
    330330                damage = true;
    331        
     331
    332332        window_yield(term->widget.window);
    333        
     333
    334334        if (damage)
    335335                window_damage(term->widget.window);
    336        
     336
    337337        fibril_mutex_unlock(&term->mtx);
    338338}
     
    341341{
    342342        fibril_mutex_lock(&term->mtx);
    343        
     343
    344344        surface_t *surface = window_claim(term->widget.window);
    345345        if (!surface) {
     
    348348                return;
    349349        }
    350        
     350
    351351        sysarg_t sx = term->widget.hpos;
    352352        sysarg_t sy = term->widget.vpos;
    353        
     353
    354354        if (!term_update_scroll(term, surface, sx, sy)) {
    355355                for (sysarg_t y = 0; y < term->rows; y++) {
     
    359359                                charfield_t *back_field =
    360360                                    chargrid_charfield_at(term->backbuf, x, y);
    361                                
     361
    362362                                back_field->ch = front_field->ch;
    363363                                back_field->attrs = front_field->attrs;
    364364                                front_field->flags &= ~CHAR_FLAG_DIRTY;
    365                                
     365
    366366                                term_update_char(term, surface, sx, sy, x, y);
    367367                        }
    368368                }
    369369        }
    370        
     370
    371371        term_update_cursor(term, surface, sx, sy);
    372        
     372
    373373        window_yield(term->widget.window);
    374374        window_damage(term->widget.window);
    375        
     375
    376376        fibril_mutex_unlock(&term->mtx);
    377377}
     
    392392        uint8_t *bbuf = buf;
    393393        size_t pos = 0;
    394        
     394
    395395        /*
    396396         * Read input from keyboard and copy it to the buffer.
     
    403403                        bbuf[pos] = term->char_remains[0];
    404404                        pos++;
    405                        
     405
    406406                        /* Unshift the array. */
    407407                        for (size_t i = 1; i < term->char_remains_len; i++)
    408408                                term->char_remains[i - 1] = term->char_remains[i];
    409                        
     409
    410410                        term->char_remains_len--;
    411411                }
    412                
     412
    413413                /* Still not enough? Then get another key from the queue. */
    414414                if (pos < size) {
    415415                        link_t *link = prodcons_consume(&term->input_pc);
    416416                        cons_event_t *event = list_get_instance(link, cons_event_t, link);
    417                        
     417
    418418                        /* Accept key presses of printable chars only. */
    419419                        if (event->type == CEV_KEY && event->ev.key.type == KEY_PRESS &&
     
    423423                                        0
    424424                                };
    425                                
     425
    426426                                wstr_to_str(term->char_remains, UTF8_CHAR_BUFFER_SIZE, tmp);
    427427                                term->char_remains_len = str_size(term->char_remains);
    428428                        }
    429                        
     429
    430430                        free(event);
    431431                }
    432432        }
    433        
     433
    434434        *nread = size;
    435435        return EOK;
     
    439439{
    440440        sysarg_t updated = 0;
    441        
    442         fibril_mutex_lock(&term->mtx);
    443        
     441
     442        fibril_mutex_lock(&term->mtx);
     443
    444444        switch (ch) {
    445445        case '\n':
     
    457457                updated = chargrid_putchar(term->frontbuf, ch, true);
    458458        }
    459        
    460         fibril_mutex_unlock(&term->mtx);
    461        
     459
     460        fibril_mutex_unlock(&term->mtx);
     461
    462462        if (updated > 1)
    463463                term_update(term);
     
    467467{
    468468        terminal_t *term = srv_to_terminal(srv);
    469        
     469
    470470        size_t off = 0;
    471471        while (off < size)
    472472                term_write_char(term, str_decode(data, &off, size));
    473        
     473
    474474        *nwritten = size;
    475475        return EOK;
     
    479479{
    480480        terminal_t *term = srv_to_terminal(srv);
    481        
     481
    482482        term_update(term);
    483483}
     
    486486{
    487487        terminal_t *term = srv_to_terminal(srv);
    488        
     488
    489489        fibril_mutex_lock(&term->mtx);
    490490        chargrid_clear(term->frontbuf);
    491491        fibril_mutex_unlock(&term->mtx);
    492        
     492
    493493        term_update(term);
    494494}
     
    497497{
    498498        terminal_t *term = srv_to_terminal(srv);
    499        
     499
    500500        fibril_mutex_lock(&term->mtx);
    501501        chargrid_set_cursor(term->frontbuf, col, row);
    502502        fibril_mutex_unlock(&term->mtx);
    503        
     503
    504504        term_update(term);
    505505}
     
    508508{
    509509        terminal_t *term = srv_to_terminal(srv);
    510        
     510
    511511        fibril_mutex_lock(&term->mtx);
    512512        chargrid_get_cursor(term->frontbuf, col, row);
    513513        fibril_mutex_unlock(&term->mtx);
    514        
     514
    515515        return EOK;
    516516}
     
    519519{
    520520        terminal_t *term = srv_to_terminal(srv);
    521        
     521
    522522        fibril_mutex_lock(&term->mtx);
    523523        *cols = term->cols;
    524524        *rows = term->rows;
    525525        fibril_mutex_unlock(&term->mtx);
    526        
     526
    527527        return EOK;
    528528}
     
    532532        (void) srv;
    533533        *caps = TERM_CAPS;
    534        
     534
    535535        return EOK;
    536536}
     
    539539{
    540540        terminal_t *term = srv_to_terminal(srv);
    541        
     541
    542542        fibril_mutex_lock(&term->mtx);
    543543        chargrid_set_style(term->frontbuf, style);
     
    549549{
    550550        terminal_t *term = srv_to_terminal(srv);
    551        
     551
    552552        fibril_mutex_lock(&term->mtx);
    553553        chargrid_set_color(term->frontbuf, bgcolor, fgcolor, attr);
     
    559559{
    560560        terminal_t *term = srv_to_terminal(srv);
    561        
     561
    562562        fibril_mutex_lock(&term->mtx);
    563563        chargrid_set_rgb_color(term->frontbuf, bgcolor, fgcolor);
     
    568568{
    569569        terminal_t *term = srv_to_terminal(srv);
    570        
     570
    571571        fibril_mutex_lock(&term->mtx);
    572572        chargrid_set_cursor_visibility(term->frontbuf, visible);
    573573        fibril_mutex_unlock(&term->mtx);
    574        
     574
    575575        term_update(term);
    576576}
     
    581581        link_t *link = prodcons_consume(&term->input_pc);
    582582        cons_event_t *ev = list_get_instance(link, cons_event_t, link);
    583        
     583
    584584        *event = *ev;
    585585        free(ev);
     
    591591        list_remove(&term->link);
    592592        widget_deinit(&term->widget);
    593        
     593
    594594        if (term->frontbuf)
    595595                chargrid_destroy(term->frontbuf);
    596        
     596
    597597        if (term->backbuf)
    598598                chargrid_destroy(term->backbuf);
     
    602602{
    603603        terminal_t *term = (terminal_t *) widget;
    604        
     604
    605605        deinit_terminal(term);
    606606        free(term);
     
    616616{
    617617        terminal_t *term = (terminal_t *) widget;
    618        
     618
    619619        widget_modify(widget, hpos, vpos, width, height);
    620620        widget->width_ideal = width;
    621621        widget->height_ideal = height;
    622        
     622
    623623        term_damage(term);
    624624}
     
    627627{
    628628        terminal_t *term = (terminal_t *) widget;
    629        
     629
    630630        term_damage(term);
    631631}
     
    638638        if (event == NULL)
    639639                return;
    640        
     640
    641641        *event = *ev;
    642642        link_initialize(&event->link);
    643        
     643
    644644        prodcons_produce(&term->input_pc, &event->link);
    645645}
     
    651651        terminal_t *term = (terminal_t *) widget;
    652652        cons_event_t event;
    653        
     653
    654654        event.type = CEV_KEY;
    655655        event.ev.key = kbd_event;
    656        
     656
    657657        terminal_queue_cons_event(term, &event);
    658658}
     
    680680{
    681681        terminal_t *term = NULL;
    682        
     682
    683683        list_foreach(terms, link, terminal_t, cur) {
    684684                if (cur->dsid == (service_id_t) IPC_GET_ARG2(*icall)) {
     
    687687                }
    688688        }
    689        
     689
    690690        if (term == NULL) {
    691691                async_answer_0(iid, ENOENT);
    692692                return;
    693693        }
    694        
     694
    695695        if (atomic_postinc(&term->refcnt) == 0)
    696696                chargrid_set_cursor_visibility(term->frontbuf, true);
    697        
     697
    698698        con_conn(iid, icall, &term->srvs);
    699699}
     
    703703{
    704704        widget_init(&term->widget, parent, data);
    705        
     705
    706706        link_initialize(&term->link);
    707707        fibril_mutex_initialize(&term->mtx);
    708708        atomic_set(&term->refcnt, 0);
    709        
     709
    710710        prodcons_initialize(&term->input_pc);
    711711        term->char_remains_len = 0;
    712        
     712
    713713        term->widget.width = width;
    714714        term->widget.height = height;
    715715        term->widget.width_ideal = width;
    716716        term->widget.height_ideal = height;
    717        
     717
    718718        term->widget.destroy = terminal_destroy;
    719719        term->widget.reconfigure = terminal_reconfigure;
     
    722722        term->widget.handle_keyboard_event = terminal_handle_keyboard_event;
    723723        term->widget.handle_position_event = terminal_handle_position_event;
    724        
     724
    725725        term->cols = width / FONT_WIDTH;
    726726        term->rows = height / FONT_SCANLINES;
    727        
     727
    728728        term->frontbuf = NULL;
    729729        term->backbuf = NULL;
    730        
     730
    731731        term->frontbuf = chargrid_create(term->cols, term->rows,
    732732            CHARGRID_FLAG_NONE);
     
    735735                return false;
    736736        }
    737        
     737
    738738        term->backbuf = chargrid_create(term->cols, term->rows,
    739739            CHARGRID_FLAG_NONE);
     
    742742                return false;
    743743        }
    744        
     744
    745745        chargrid_clear(term->frontbuf);
    746746        chargrid_clear(term->backbuf);
    747747        term->top_row = 0;
    748        
     748
    749749        async_set_fallback_port_handler(term_connection, NULL);
    750750        con_srvs_init(&term->srvs);
    751751        term->srvs.ops = &con_ops;
    752752        term->srvs.sarg = term;
    753        
     753
    754754        errno_t rc = loc_server_register(NAME);
    755755        if (rc != EOK) {
     
    757757                return false;
    758758        }
    759        
     759
    760760        char vc[LOC_NAME_MAXLEN + 1];
    761761        snprintf(vc, LOC_NAME_MAXLEN, "%s/%" PRIu64, NAMESPACE,
    762762            task_get_id());
    763        
     763
    764764        rc = loc_service_register(vc, &term->dsid);
    765765        if (rc != EOK) {
     
    767767                return false;
    768768        }
    769        
     769
    770770        list_append(&term->link, &terms);
    771771        getterm(vc, "/app/bdsh");
    772        
     772
    773773        return true;
    774774}
     
    780780        if (!term)
    781781                return NULL;
    782        
     782
    783783        bool ret = init_terminal(term, parent, data, width, height);
    784784        if (!ret) {
     
    786786                return NULL;
    787787        }
    788        
     788
    789789        return term;
    790790}
Note: See TracChangeset for help on using the changeset viewer.