Ticket #2229: mc-skip_useless_display_updates.patch

File mc-skip_useless_display_updates.patch, 12.0 KB (added by gotar, 12 years ago)
  • actions_cmd.c

    diff -urp /home/users/gotar/git/mc/src/viewer/actions_cmd.c ./actions_cmd.c
    old new mcview_handle_editkey (mcview_t * view,  
    242242 
    243243/* --------------------------------------------------------------------------------------------- */ 
    244244 
    245 static cb_ret_t 
     245static int 
    246246mcview_execute_cmd (mcview_t * view, unsigned long command) 
    247247{ 
    248248    int res = MSG_HANDLED; 
    mcview_execute_cmd (mcview_t * view, uns 
    297297        view->dirty++; 
    298298        break; 
    299299    case CK_ViewMoveToBol: 
    300         mcview_moveto_bol (view); 
     300        return mcview_moveto_bol (view); 
    301301        break; 
    302302    case CK_ViewMoveToEol: 
    303303        mcview_moveto_eol (view); 
    304304        break; 
    305305    case CK_ViewMoveLeft: 
    306         mcview_move_left (view, 1); 
    307         break; 
     306        return mcview_move_left (view, 1); 
    308307    case CK_ViewMoveRight: 
    309308        mcview_move_right (view, 1); 
    310309        break; 
    311310    case CK_ViewMoveLeft10: 
    312311        if (!view->hex_mode) 
    313             mcview_move_left (view, 10); 
    314         break; 
     312            return mcview_move_left (view, 10); 
     313        return -MSG_HANDLED; 
    315314    case CK_ViewMoveRight10: 
    316315        if (!view->hex_mode) 
    317316            mcview_move_right (view, 10); 
    mcview_execute_cmd (mcview_t * view, uns 
    323322        mcview_display_toggle_ruler (view); 
    324323        break; 
    325324    case CK_ViewMoveUp: 
    326         mcview_move_up (view, 1); 
    327         break; 
     325        return mcview_move_up (view, 1); 
    328326    case CK_ViewMoveDown: 
    329327        mcview_move_down (view, 1); 
    330328        break; 
    331329    case CK_ViewMoveHalfPgUp: 
    332         mcview_move_up (view, (view->data_area.height + 1) / 2); 
    333         break; 
     330        return mcview_move_up (view, (view->data_area.height + 1) / 2); 
    334331    case CK_ViewMoveHalfPgDn: 
    335332        mcview_move_down (view, (view->data_area.height + 1) / 2); 
    336333        break; 
    337334    case CK_ViewMovePgUp: 
    338         mcview_move_up (view, view->data_area.height); 
    339         break; 
     335        return mcview_move_up (view, view->data_area.height); 
    340336    case CK_ViewMovePgDn: 
    341337        mcview_move_down (view, view->data_area.height); 
    342338        break; 
    343339    case CK_ViewMoveTop: 
    344         mcview_moveto_top (view); 
    345         break; 
     340        return mcview_moveto_top (view); 
    346341    case CK_ViewMoveBottom: 
    347342        mcview_moveto_bottom (view); 
    348343        break; 
    349344    case CK_ShowCommandLine: 
    350345        view_other_cmd (); 
    351         break; 
     346        return -MSG_HANDLED; 
    352347        /* 
    353348           // Unlike Ctrl-O, run a new shell if the subshell is not running 
    354349           case '!': 
    mcview_execute_cmd (mcview_t * view, uns 
    376371    case CK_ViewQuit: 
    377372        if (!mcview_is_in_panel (view)) 
    378373            dlg_stop (view->widget.owner); 
    379         break; 
     374        return -MSG_HANDLED; 
    380375    default: 
    381376        res = MSG_NOT_HANDLED; 
    382377    } 
    mcview_execute_cmd (mcview_t * view, uns 
    384379} 
    385380 
    386381/* Both views */ 
    387 static cb_ret_t 
     382static int 
    388383mcview_handle_key (mcview_t * view, int key) 
    389384{ 
    390385    unsigned long command; 
     386    int res; 
    391387 
    392388    key = convert_from_input_c (key); 
    393389 
    mcview_handle_key (mcview_t * view, int  
    402398    } 
    403399 
    404400    command = lookup_keymap_command (view->plain_map, key); 
    405     if ((command != CK_Ignore_Key) && (mcview_execute_cmd (view, command) == MSG_HANDLED)) 
    406         return MSG_HANDLED; 
     401    if (command != CK_Ignore_Key) 
     402    { 
     403        res = mcview_execute_cmd (view, command); 
     404        if (res != MSG_NOT_HANDLED) 
     405            return res; 
     406    } 
    407407 
    408408#ifdef MC_ENABLE_DEBUGGING_CODE 
    409409    if (c == 't') 
    cb_ret_t 
    450450mcview_callback (Widget * w, widget_msg_t msg, int parm) 
    451451{ 
    452452    mcview_t *view = (mcview_t *) w; 
    453     cb_ret_t i; 
     453    int i; 
    454454 
    455455    mcview_compute_areas (view); 
    456456    mcview_update_bytes_per_line (view); 
    mcview_callback (Widget * w, widget_msg_ 
    475475 
    476476    case WIDGET_KEY: 
    477477        i = mcview_handle_key (view, parm); 
    478         mcview_update (view); 
    479         return i; 
     478        if (i != MSG_NOT_HANDLED && i != -MSG_HANDLED) 
     479            mcview_update (view); 
     480        if (i != MSG_NOT_HANDLED) 
     481            return MSG_HANDLED; 
     482        return MSG_NOT_HANDLED; 
    480483 
    481484    case WIDGET_COMMAND: 
    482485        i = mcview_execute_cmd (view, parm); 
  • datasource.c

    diff -urp /home/users/gotar/git/mc/src/viewer/datasource.c ./datasource.c
    old new mcview_get_ptr_file (mcview_t * view, of 
    136136{ 
    137137    assert (view->datasource == DS_FILE); 
    138138 
    139     mcview_file_load_data (view, byte_index); 
    140     if (mcview_already_loaded (view->ds_file_offset, byte_index, view->ds_file_datalen)) 
     139    if (mcview_file_load_data (view, byte_index)) 
    141140        return (char *) (view->ds_file_data + (byte_index - view->ds_file_offset)); 
    142141    return NULL; 
    143142} 
    mcview_set_byte (mcview_t * view, off_t  
    259258/* --------------------------------------------------------------------------------------------- */ 
    260259 
    261260/*static */ 
    262 void 
     261gboolean 
    263262mcview_file_load_data (mcview_t * view, off_t byte_index) 
    264263{ 
    265264    off_t blockoffset; 
    mcview_file_load_data (mcview_t * view,  
    269268    assert (view->datasource == DS_FILE); 
    270269 
    271270    if (mcview_already_loaded (view->ds_file_offset, byte_index, view->ds_file_datalen)) 
    272         return; 
     271        return TRUE; 
    273272 
    274273    if (byte_index >= view->ds_file_filesize) 
    275         return; 
     274        return FALSE; 
    276275 
    277276    blockoffset = mcview_offset_rounddown (byte_index, view->ds_file_datasize); 
    278277    if (mc_lseek (view->ds_file_fd, blockoffset, SEEK_SET) == -1) 
    mcview_file_load_data (mcview_t * view,  
    300299    { 
    301300        view->ds_file_datalen = bytes_read; 
    302301    } 
    303     return; 
     302    return TRUE; 
    304303 
    305304  error: 
    306305    view->ds_file_datalen = 0; 
     306    return FALSE; 
    307307} 
    308308 
    309309/* --------------------------------------------------------------------------------------------- */ 
  • display.c

    diff -urp /home/users/gotar/git/mc/src/viewer/display.c ./display.c
    old new mcview_update (mcview_t * view) 
    183183{ 
    184184    static int dirt_limit = 1; 
    185185 
     186    /* don't update viewer in inactive dialog */ 
     187    if (view->widget.owner->state != DLG_ACTIVE) 
     188        return; 
     189 
    186190    if (view->dpy_bbar_dirty) 
    187191    { 
    188192        view->dpy_bbar_dirty = FALSE; 
  • inlines.h

    diff -urp /home/users/gotar/git/mc/src/viewer/inlines.h ./inlines.h
    old new mcview_get_byte_file (mcview_t * view, o 
    8080{ 
    8181    assert (view->datasource == DS_FILE); 
    8282 
    83     mcview_file_load_data (view, byte_index); 
    84     if (mcview_already_loaded (view->ds_file_offset, byte_index, view->ds_file_datalen)) 
     83    if (mcview_file_load_data (view, byte_index)) 
    8584    { 
    8685        if (retval) 
    8786            *retval = view->ds_file_data[byte_index - view->ds_file_offset]; 
  • internal.h

    diff -urp /home/users/gotar/git/mc/src/viewer/internal.h ./internal.h
    old new int mcview_get_utf (mcview_t *, off_t, i 
    242242gboolean mcview_get_byte_string (mcview_t *, off_t, int *); 
    243243gboolean mcview_get_byte_none (mcview_t *, off_t, int *); 
    244244void mcview_set_byte (mcview_t *, off_t, byte); 
    245 void mcview_file_load_data (mcview_t *, off_t); 
     245gboolean mcview_file_load_data (mcview_t *, off_t); 
    246246void mcview_close_datasource (mcview_t *); 
    247247void mcview_set_datasource_file (mcview_t *, int, const struct stat *); 
    248248gboolean mcview_load_command_output (mcview_t *, const char *); 
    gboolean mcview_lock_file (mcview_t * vi 
    296296gboolean mcview_unlock_file (mcview_t * view); 
    297297 
    298298/* move.c */ 
    299 void mcview_move_up (mcview_t *, off_t); 
     299int mcview_move_up (mcview_t *, off_t); 
    300300void mcview_move_down (mcview_t *, off_t); 
    301 void mcview_move_left (mcview_t *, off_t); 
     301int mcview_move_left (mcview_t *, off_t); 
    302302void mcview_move_right (mcview_t *, off_t); 
    303303void mcview_scroll_to_cursor (mcview_t *); 
    304 void mcview_moveto_top (mcview_t *); 
     304int mcview_moveto_top (mcview_t *); 
    305305void mcview_moveto_bottom (mcview_t *); 
    306 void mcview_moveto_bol (mcview_t *); 
     306int mcview_moveto_bol (mcview_t *); 
    307307void mcview_moveto_eol (mcview_t *); 
    308308void mcview_moveto_offset (mcview_t *, off_t); 
    309309void mcview_moveto (mcview_t *, off_t, off_t); 
  • move.c

    diff -urp /home/users/gotar/git/mc/src/viewer/move.c ./move.c
    old new mcview_movement_fixups (mcview_t * view, 
    8585 
    8686/* --------------------------------------------------------------------------------------------- */ 
    8787 
    88 void 
     88int 
    8989mcview_move_up (mcview_t * view, off_t lines) 
    9090{ 
    91     off_t new_offset; 
     91    off_t new_offset, i; 
    9292 
    9393    if (view->hex_mode) 
    9494    { 
     95        i = MSG_HANDLED;        /* in this mode actual linecount doesn't matter */ 
    9596        off_t bytes = lines * view->bytes_per_line; 
    9697        if (view->hex_cursor >= bytes) 
    9798        { 
    mcview_move_up (mcview_t * view, off_t l 
    106107    } 
    107108    else 
    108109    { 
    109         off_t i; 
    110110 
    111111        for (i = 0; i < lines; i++) 
    112112        { 
    mcview_move_up (mcview_t * view, off_t l 
    147147            } 
    148148        } 
    149149    } 
     150    if (i == 0) return -MSG_HANDLED; 
    150151    mcview_movement_fixups (view, TRUE); 
     152    return i; 
    151153} 
    152154 
    153155/* --------------------------------------------------------------------------------------------- */ 
    mcview_move_down (mcview_t * view, off_t 
    220222 
    221223/* --------------------------------------------------------------------------------------------- */ 
    222224 
    223 void 
     225int 
    224226mcview_move_left (mcview_t * view, off_t columns) 
    225227{ 
     228    int ret; 
     229    ret = -MSG_HANDLED; 
     230 
    226231    if (view->hex_mode) 
    227232    { 
     233        ret = MSG_HANDLED; 
    228234        off_t old_cursor = view->hex_cursor; 
    229235        assert (columns == 1); 
    230236        if (view->hexview_in_text || !view->hexedit_lownibble) 
    mcview_move_left (mcview_t * view, off_t 
    239245    else 
    240246    { 
    241247        if (view->dpy_text_column >= columns) 
     248        { 
    242249            view->dpy_text_column -= columns; 
    243         else 
     250            ret = columns; 
     251        } 
     252        else { 
     253            if (view->dpy_text_column > 0) 
     254                ret = view->dpy_text_column; 
    244255            view->dpy_text_column = 0; 
     256        } 
    245257    } 
    246258    mcview_movement_fixups (view, FALSE); 
     259    return ret; 
    247260} 
    248261 
    249262/* --------------------------------------------------------------------------------------------- */ 
    mcview_scroll_to_cursor (mcview_t * view 
    295308 
    296309/* --------------------------------------------------------------------------------------------- */ 
    297310 
    298 void 
     311int 
    299312mcview_moveto_top (mcview_t * view) 
    300313{ 
     314    int ret; 
     315    ret = -MSG_HANDLED; 
     316 
     317    if (view->dpy_start > 0 || view->hex_cursor > 0 || view->dpy_text_column > 0) 
     318        ret = MSG_HANDLED; 
     319         
    301320    view->dpy_start = 0; 
    302321    view->hex_cursor = 0; 
    303322    view->dpy_text_column = 0; 
    304323    mcview_movement_fixups (view, TRUE); 
     324    return ret; 
    305325} 
    306326 
    307327/* --------------------------------------------------------------------------------------------- */ 
    mcview_moveto_bottom (mcview_t * view) 
    334354 
    335355/* --------------------------------------------------------------------------------------------- */ 
    336356 
    337 void 
     357int 
    338358mcview_moveto_bol (mcview_t * view) 
    339359{ 
     360    int ret; 
     361    ret = -MSG_HANDLED; 
    340362    if (view->hex_mode) 
    341363    { 
     364        ret = MSG_HANDLED; 
    342365        view->hex_cursor -= view->hex_cursor % view->bytes_per_line; 
    343366    } 
    344367    else if (!view->text_wrap_mode) 
    345368    { 
     369        /* this doesn't seem to do anything, according to this file header this is always the beginning of current line */ 
    346370        view->dpy_start = mcview_bol (view, view->dpy_start, 0); 
    347371    } 
     372    if (view->dpy_text_column > 0) 
     373        ret = view->dpy_text_column; 
    348374    view->dpy_text_column = 0; 
    349375    mcview_movement_fixups (view, TRUE); 
     376    return ret; 
    350377} 
    351378 
    352379/* --------------------------------------------------------------------------------------------- */