Changeset a35b458 in mainline for uspace/app/fontviewer/fontviewer.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/app/fontviewer/fontviewer.c

    r3061bc1 ra35b458  
    6868{
    6969        kbd_event_t *event = (kbd_event_t *) data;
    70        
     70
    7171        if (event->type == KEY_PRESS) {
    7272                if (event->c == 'q')
    7373                        exit(0);
    74                
     74
    7575                if (event->key == KC_UP || event->key == KC_DOWN) {
    7676                        uint16_t increment = (event->mods & KM_SHIFT) ? 10 : 1;
     
    7878                        if (event->key == KC_UP)
    7979                                points += increment;
    80                
     80
    8181                        if (event->key == KC_DOWN) {
    8282                                if (points <= increment) {
     
    8787                                }
    8888                        }
    89                        
     89
    9090                        if (points < 1)
    9191                                points = 1;
    9292                }
    93                
     93
    9494                if (event->c == 'm')
    9595                        show_metrics = !show_metrics;
    9696        }
    97        
     97
    9898        errno_t rc = draw();
    9999        if (rc != EOK) {
     
    109109                return embedded_font_create(font, points);
    110110        }
    111        
     111
    112112        return pcf_font_create(font, font_path, points);
    113113}
     
    127127        if (y2 < y1)
    128128                return;
    129        
     129
    130130        drawctx_set_source(drawctx, source);
    131131        drawctx_transfer(drawctx, x1, y1, x2 - x1 + 1, y2 - y1 + 1);
     
    148148        int ret = vasprintf(&str, fmt, args);
    149149        va_end(args);
    150        
     150
    151151        if (ret >= 0) {
    152152                drawctx_set_source(drawctx, source);
     
    156156                free(str);
    157157        }
    158        
     158
    159159        return ret;
    160160}
     
    172172        source_t leading_bg = rgb(170, 238, 255);
    173173        source_t leading_fg = rgb(0, 170, 212);
    174        
     174
    175175        font_t *font;
    176176        errno_t rc = create_font(&font, points);
     
    179179                return rc;
    180180        }
    181        
     181
    182182        font_t *info_font;
    183183        rc = embedded_font_create(&info_font, 16);
     
    186186                return rc;
    187187        }
    188        
     188
    189189        font_metrics_t font_metrics;
    190190        rc = font_get_metrics(font, &font_metrics);
    191191        if (rc != EOK)
    192192                return rc;
    193        
     193
    194194        surface_coord_t top = 50;
    195195        metric_t ascender_top = top;
     
    200200        drawctx_t drawctx;
    201201        drawctx_init(&drawctx, surface);
    202        
     202
    203203        drawctx_set_source(&drawctx, &background);
    204204        drawctx_transfer(&drawctx, 0, 0,
    205205            width, height);
    206        
     206
    207207        if (show_metrics) {
    208208                horizontal_rectangle(&drawctx, 0, ascender_top, width,
     
    210210                horizontal_line(&drawctx, ascender_top, 0, width,
    211211                    &ascender_fg);
    212                
     212
    213213                horizontal_rectangle(&drawctx, 0, descender_top, width,
    214214                    leading_top - 1, &descender_bg);
    215215                horizontal_line(&drawctx, descender_top, 0, width,
    216216                    &descender_fg);
    217                
     217
    218218                horizontal_rectangle(&drawctx, 0, leading_top,
    219219                    width, line_bottom - 1, &leading_bg);
     
    221221                    &leading_fg);
    222222        }
    223        
     223
    224224        drawctx_set_source(&drawctx, &glyphs);
    225225        drawctx_set_font(&drawctx, font);
    226226        drawctx_print(&drawctx, "Čaj'_", 0, top);
    227        
     227
    228228        if (show_metrics) {
    229229                surface_coord_t infos_top = line_bottom + 10;
     
    239239
    240240        }
    241        
     241
    242242        font_release(font);
    243243        return EOK;
     
    250250                return 1;
    251251        }
    252        
     252
    253253        if (argc < 3) {
    254254                font_path = NULL;
     
    257257                font_path = argv[2];
    258258        }
    259        
     259
    260260        main_window = window_open(argv[1], NULL, WINDOW_MAIN, "fontviewer");
    261261        if (!main_window) {
     
    263263                return 2;
    264264        }
    265        
     265
    266266        surface = surface_create(WINDOW_WIDTH, WINDOW_HEIGHT, NULL,
    267267            SURFACE_FLAG_NONE);
     
    270270                return 2;
    271271        }
    272        
     272
    273273        width = WINDOW_WIDTH;
    274274        height = WINDOW_HEIGHT;
    275        
     275
    276276        errno_t rc = draw();
    277277        if (rc != EOK) {
     
    279279                return 2;
    280280        }
    281        
     281
    282282        canvas = create_canvas(window_root(main_window), NULL,
    283283            WINDOW_WIDTH, WINDOW_HEIGHT, surface);
     
    287287        }
    288288        sig_connect(&canvas->keyboard_event, NULL, on_keyboard_event);
    289        
     289
    290290        window_resize(main_window, 200, 200, WINDOW_WIDTH, WINDOW_HEIGHT,
    291291            WINDOW_PLACEMENT_ABSOLUTE);
    292292        window_exec(main_window);
    293        
     293
    294294        task_retval(0);
    295295        async_manager();
    296        
     296
    297297        return 0;
    298298}
Note: See TracChangeset for help on using the changeset viewer.