Changeset 49d072e in mainline for fb/fb.c


Ignore:
Timestamp:
2006-06-02T10:54:45Z (19 years ago)
Author:
Ondrej Palkovsky <ondrap@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
bf9afa07
Parents:
838c48e
Message:

Added blinking cursor.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • fb/fb.c

    r838c48e r49d072e  
    7777        /* Auto-cursor position */
    7878        int cursor_active, cur_col, cur_row;
     79        int cursor_shown;
    7980} viewport_t;
    8081
     
    396397}
    397398
     399static void cursor_hide(int vp)
     400{
     401        viewport_t *vport = &viewports[vp];
     402
     403        if (vport->cursor_active && vport->cursor_shown) {
     404                invert_char(vp, vport->cur_row, vport->cur_col);
     405                vport->cursor_shown = 0;
     406        }
     407}
     408
     409static void cursor_print(int vp)
     410{
     411        viewport_t *vport = &viewports[vp];
     412
     413        /* Do not check for cursor_shown */
     414        if (vport->cursor_active) {
     415                invert_char(vp, vport->cur_row, vport->cur_col);
     416                vport->cursor_shown = 1;
     417        }
     418}
     419
     420static void cursor_blink(int vp)
     421{
     422        viewport_t *vport = &viewports[vp];
     423
     424        if (vport->cursor_shown)
     425                cursor_hide(vp);
     426        else
     427                cursor_print(vp);
     428}
     429
    398430/** Draw character at given position relative to viewport
    399431 *
     
    407439        viewport_t *vport = &viewports[vp];
    408440
    409         if (vport->cursor_active && (vport->cur_col != col || vport->cur_row != row))
     441        /* Optimize - do not hide cursor if we are going to overwrite it */
     442        if (vport->cursor_active && vport->cursor_shown &&
     443            (vport->cur_col != col || vport->cur_row != row))
    410444                invert_char(vp, vport->cur_row, vport->cur_col);
    411445       
     
    422456                        vport->cur_row--;
    423457        }
    424         if (vport->cursor_active)
    425                 invert_char(vp, vport->cur_row, vport->cur_col);
     458        cursor_print(vp);
    426459}
    427460
     
    449482
    450483        while (1) {
    451                 callid = async_get_call(&call);
     484                callid = async_get_call_timeout(&call,250000);
     485                if (!callid) {
     486                        cursor_blink(vp);
     487                        continue;
     488                }
    452489                switch (IPC_GET_METHOD(call)) {
    453490                case IPC_M_PHONE_HUNGUP:
     
    472509                case FB_CLEAR:
    473510                        clear_port(vp);
    474                         if (vport->cursor_active)
    475                                 invert_char(vp, vport->cur_row, vport->cur_col);
     511                        cursor_print(vp);
    476512                        retval = 0;
    477513                        break;
     
    484520                        }
    485521                        retval = 0;
    486                         if (viewports[vp].cursor_active) {
    487                                 invert_char(vp, vport->cur_row, vport->cur_col);
    488                                 invert_char(vp, row, col);
    489                         }
     522                        cursor_hide(vp);
    490523                        vport->cur_col = col;
    491524                        vport->cur_row = row;
     525                        cursor_print(vp);
    492526                        break;
    493527                case FB_CURSOR_VISIBILITY:
    494                         i = IPC_GET_ARG1(call);
     528                        cursor_hide(vp);
     529                        vport->cursor_active = IPC_GET_ARG1(call);
     530                        cursor_print(vp);
    495531                        retval = 0;
    496                         if ((i && vport->cursor_active) || (!i && !vport->cursor_active))
    497                                 break;
    498 
    499                         vport->cursor_active = i;
    500                         invert_char(vp, vport->cur_row, vport->cur_col);
    501532                        break;
    502533                case FB_GET_CSIZE:
     
    509540                                break;
    510541                        }
    511                         if (vport->cursor_active)
    512                                 invert_char(vp, vport->cur_row, vport->cur_col);
     542                        cursor_hide(vp);
    513543                        scroll_port(vp, i);
    514                         if (vport->cursor_active)
    515                                 invert_char(vp, vport->cur_row, vport->cur_col);
     544                        cursor_print(vp);
    516545                        retval = 0;
    517546                        break;
     
    526555                                break;
    527556                        }
     557                        cursor_hide(vp);
    528558                        vp = i;
    529559                        vport = &viewports[vp];
     560                        cursor_print(vp);
    530561                        retval = 0;
    531562                        break;
Note: See TracChangeset for help on using the changeset viewer.