Changeset a35b458 in mainline for uspace/dist/src/c/demos/edit/edit.c


Ignore:
Timestamp:
2018-03-02T20:10:49Z (7 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f1380b7
Parents:
3061bc1
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
Message:

style: Remove trailing whitespace on _all_ lines, including empty ones, for particular file types.

Command used: tools/srepl '\s\+$' '' -- *.c *.h *.py *.sh *.s *.S *.ag

Currently, whitespace on empty lines is very inconsistent.
There are two basic choices: Either remove the whitespace, or keep empty lines
indented to the level of surrounding code. The former is AFAICT more common,
and also much easier to do automatically.

Alternatively, we could write script for automatic indentation, and use that
instead. However, if such a script exists, it's possible to use the indented
style locally, by having the editor apply relevant conversions on load/save,
without affecting remote repository. IMO, it makes more sense to adopt
the simpler rule.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/dist/src/c/demos/edit/edit.c

    r3061bc1 ra35b458  
    8888         */
    8989        int ideal_column;
    90        
     90
    9191        char *previous_search;
    9292        bool previous_search_reverse;
     
    532532                pane.rflags |= REDRAW_TEXT;
    533533        }
    534        
     534
    535535        if (update_ideal_column)
    536536                pane.ideal_column = c_new.column;
    537        
     537
    538538        caret_update();
    539539}
     
    608608        const char *old_fname = (doc.file_name != NULL) ? doc.file_name : "";
    609609        char *fname;
    610        
     610
    611611        fname = prompt("Save As", old_fname);
    612612        if (fname == NULL) {
     
    815815
    816816        /* Clear the remaining rows if file is short. */
    817        
     817
    818818        int i;
    819819        sysarg_t j;
     
    905905                                console_flush(con);
    906906                        }
    907        
     907
    908908                        if ((csel_end.row == rbc.row) && (csel_end.column == s_column)) {
    909909                                console_flush(con);
     
    911911                                console_flush(con);
    912912                        }
    913        
     913
    914914                        c = str_decode(row_buf, &pos, size);
    915915                        if (c != '\t') {
     
    966966        int n = printf(" %d, %d (%d): File '%s'. Ctrl-Q Quit  Ctrl-S Save  "
    967967            "Ctrl-E Save As", coord.row, coord.column, last_row, fname);
    968        
     968
    969969        int pos = scr_columns - 1 - n;
    970970        printf("%*s", pos, "");
     
    11511151        coord.row = row;
    11521152        coord.column = column;
    1153        
     1153
    11541154        spt_t pt;
    11551155        sheet_get_cell_pt(doc.sh, &coord, align_dir, &pt);
    1156        
     1156
    11571157        caret_move(pt, select, true);
    11581158}
     
    11961196{
    11971197        char *sline;
    1198        
     1198
    11991199        sline = prompt("Go to line", "");
    12001200        if (sline == NULL) {
     
    12021202                return;
    12031203        }
    1204        
     1204
    12051205        char *endptr;
    12061206        int line = strtol(sline, &endptr, 10);
     
    12111211        }
    12121212        free(sline);
    1213        
     1213
    12141214        caret_move_absolute(line, pane.ideal_column, dir_before, false);
    12151215}
     
    12701270{
    12711271        char *pattern;
    1272        
     1272
    12731273        const char *prompt_text = "Find next";
    12741274        if (reverse)
    12751275                prompt_text = "Find previous";
    1276        
     1276
    12771277        const char *default_value = "";
    12781278        if (pane.previous_search)
    12791279                default_value = pane.previous_search;
    1280        
     1280
    12811281        pattern = prompt(prompt_text, default_value);
    12821282        if (pattern == NULL) {
     
    12841284                return;
    12851285        }
    1286        
     1286
    12871287        if (pane.previous_search)
    12881288                free(pane.previous_search);
    12891289        pane.previous_search = pattern;
    12901290        pane.previous_search_reverse = reverse;
    1291        
     1291
    12921292        search(pattern, reverse);
    12931293}
     
    12991299                return;
    13001300        }
    1301        
     1301
    13021302        search(pane.previous_search, pane.previous_search_reverse);
    13031303}
     
    13061306{
    13071307        status_display("Searching...");
    1308        
     1308
    13091309        spt_t sp, producer_pos;
    13101310        tag_get_pt(&pane.caret_pos, &sp);
    1311        
     1311
    13121312        /* Start searching on the position before/after caret */
    13131313        if (!reverse) {
     
    13181318        }
    13191319        producer_pos = sp;
    1320        
     1320
    13211321        search_ops_t ops = search_spt_ops;
    13221322        if (reverse)
    13231323                ops = search_spt_reverse_ops;
    1324        
     1324
    13251325        search_t *search = search_init(pattern, &producer_pos, ops, reverse);
    13261326        if (search == NULL) {
     
    13281328                return;
    13291329        }
    1330        
     1330
    13311331        match_t match;
    13321332        errno_t rc = search_next_match(search, &match);
     
    13351335                search_fini(search);
    13361336        }
    1337        
     1337
    13381338        if (match.end) {
    13391339                status_display("Match found.");
     
    13561356                status_display("Not found.");
    13571357        }
    1358        
     1358
    13591359        search_fini(search);
    13601360}
     
    16491649        console_set_pos(con, 0, scr_rows - 1);
    16501650        console_set_style(con, STYLE_INVERTED);
    1651        
     1651
    16521652        int pos = -(scr_columns - 3);
    16531653        printf(" %*s ", pos, str);
Note: See TracChangeset for help on using the changeset viewer.