Ticket #1480: mc-4.8.3-4.home-end_key.patch

File mc-4.8.3-4.home-end_key.patch, 2.8 KB (added by szaszg, 7 years ago)
  • src/editor/edit-impl.h

    diff --git a/src/editor/edit-impl.h b/src/editor/edit-impl.h
    index 9b965fb..7d004b6 100644
    a b void edit_move_down (WEdit * edit, unsigned long i, int scroll); 
    200200void edit_move_to_prev_col (WEdit * edit, long p); 
    201201int edit_get_col (WEdit * edit); 
    202202long edit_bol (WEdit * edit, long current); 
     203long edit_bol_var (WEdit * edit, long current); 
    203204long edit_eol (WEdit * edit, long current); 
     205long edit_eol_var (WEdit * edit, long current); 
    204206void edit_update_curs_row (WEdit * edit); 
    205207void edit_update_curs_col (WEdit * edit); 
    206208void edit_find_bracket (WEdit * edit); 
  • src/editor/edit.c

    diff --git a/src/editor/edit.c b/src/editor/edit.c
    index 87791d6..f1398e4 100644
    a b edit_move_to_bottom (WEdit * edit) 
    10441044static void 
    10451045edit_cursor_to_bol (WEdit * edit) 
    10461046{ 
    1047     edit_cursor_move (edit, edit_bol (edit, edit->curs1) - edit->curs1); 
     1047    edit_cursor_move (edit, edit_bol_var (edit, edit->curs1) - edit->curs1); 
    10481048    edit->search_start = edit->curs1; 
    10491049    edit->prev_col = edit_get_col (edit); 
    10501050    edit->over_col = 0; 
    edit_cursor_to_bol (WEdit * edit) 
    10561056static void 
    10571057edit_cursor_to_eol (WEdit * edit) 
    10581058{ 
    1059     edit_cursor_move (edit, edit_eol (edit, edit->curs1) - edit->curs1); 
     1059    edit_cursor_move (edit, edit_eol_var (edit, edit->curs1) - edit->curs1); 
    10601060    edit->search_start = edit->curs1; 
    10611061    edit->prev_col = edit_get_col (edit); 
    10621062    edit->over_col = 0; 
    edit_set_codeset (WEdit * edit) 
    24692469#endif 
    24702470} 
    24712471 
     2472/* returns index of first char on line or the first nonspace char */ 
     2473long edit_bol_var (WEdit * edit, long current) 
     2474{ 
     2475    long tmp; 
     2476    int b; 
     2477 
     2478    if (current < 0) 
     2479        current = 0; 
     2480 
     2481    if (edit_get_byte (edit, current - 1) != '\n')     /* not at BOL */ 
     2482        return edit_bol (edit, current); 
     2483 
     2484    if (edit_get_byte (edit, current) == '\n')         /* on an empty line */ 
     2485        return current; 
     2486 
     2487    for (tmp = current; (b = edit_get_byte (edit, tmp)) != '\n'; tmp++) 
     2488        if (b != ' ' && b != '\t') 
     2489            return tmp; 
     2490    return current; 
     2491} 
     2492 
     2493/* returns index of last char on line or the last nonspace char */ 
     2494long edit_eol_var (WEdit * edit, long current) 
     2495{ 
     2496    long tmp; 
     2497    int b; 
     2498 
     2499    if (current >= edit->last_byte) 
     2500        current = edit->last_byte; 
     2501 
     2502    if (edit_get_byte (edit, current) != '\n') /* not at BOL */ 
     2503        return edit_eol (edit, current); 
     2504 
     2505    if (edit_get_byte (edit, current - 1) == '\n')             /* on an empty line */ 
     2506        return current; 
     2507 
     2508    for (tmp = current - 1; (b = edit_get_byte (edit, tmp)) != '\n'; tmp--) 
     2509        if (b != ' ' && b != '\t') 
     2510            return tmp; 
     2511    return current; 
     2512} 
    24722513 
    24732514/* --------------------------------------------------------------------------------------------- */ 
    24742515/**