xaizek / vifm (License: GPLv2+) (since 2018-12-07)
Vifm is a file manager with curses interface, which provides Vi[m]-like environment for managing objects within file systems, extended with some useful ideas from mutt.
Commit cec82621e2d367afe4d8125474d0d957faa183ee

Extract ui/ui.c:get_fileview_ruler_width()
Out of get_ruler_width() to make its body more homogeneous.
Author: xaizek
Author date (UTC): 2026-06-08 17:03
Committer name: xaizek
Committer date (UTC): 2026-06-08 17:03
Parent(s): 6a9a71d2ef537ec7cb507072dcb8eb255e5e19b2
Signing key: 99DC5E4DB05F6BE2
Tree: 8e1553ad286cf96d81e7c911127d686a6df84656
File Lines added Lines deleted
src/ui/ui.c 15 11
File src/ui/ui.c changed (mode: 100644) (index 66b56cd04..4ec4d28e3)
... ... static void update_window_lazy(WINDOW *win);
171 171 static void update_term_size(void); static void update_term_size(void);
172 172 static void update_statusbar_layout(void); static void update_statusbar_layout(void);
173 173 static int are_statusbar_widgets_visible(void); static int are_statusbar_widgets_visible(void);
174 static int get_ruler_width(view_t *view);
174 static int get_ruler_width(void);
175 static int get_fileview_ruler_width(view_t *view);
175 176 static char * expand_ruler_macros(view_t *view, const char format[]); static char * expand_ruler_macros(view_t *view, const char format[]);
176 177 static int locate_view(unsigned int id, int *tab_idx, view_t **side); static int locate_view(unsigned int id, int *tab_idx, view_t **side);
177 178 static void switch_panes_content(void); static void switch_panes_content(void);
 
... ... update_statusbar_layout(void)
1539 1540 getmaxyx(stdscr, screen_y, screen_x); getmaxyx(stdscr, screen_y, screen_x);
1540 1541
1541 1542 int max_ruler_width = screen_x - INPUT_WIN_WIDTH - 1; int max_ruler_width = screen_x - INPUT_WIN_WIDTH - 1;
1542 int ruler_width = MIN(get_ruler_width(curr_view), max_ruler_width);
1543 int ruler_width = MIN(get_ruler_width(), max_ruler_width);
1543 1544 /* The minimal start position is 1, not 0, because otherwise the ruler is /* The minimal start position is 1, not 0, because otherwise the ruler is
1544 1545 * hidden by a single-character status bar window. */ * hidden by a single-character status bar window. */
1545 1546 int fields_pos = screen_x - (INPUT_WIN_WIDTH + ruler_width); int fields_pos = screen_x - (INPUT_WIN_WIDTH + ruler_width);
 
... ... are_statusbar_widgets_visible(void)
1572 1573
1573 1574 /* Gets "recommended" width for the ruler. Returns the width. */ /* Gets "recommended" width for the ruler. Returns the width. */
1574 1575 static int static int
1575 get_ruler_width(view_t *view)
1576 get_ruler_width(void)
1576 1577 { {
1577 char *expanded;
1578 int len;
1579 int list_pos;
1580
1581 1578 if(vle_mode_is(VIEW_MODE)) if(vle_mode_is(VIEW_MODE))
1582 1579 { {
1583 1580 return modview_get_ruler_width(); return modview_get_ruler_width();
 
... ... get_ruler_width(view_t *view)
1586 1583 { {
1587 1584 return modmenu_get_ruler_width(); return modmenu_get_ruler_width();
1588 1585 } }
1586 return get_fileview_ruler_width(curr_view);
1587 }
1589 1588
1590 /* Size must correspond to the "worst case" of the last list item. */
1591 list_pos = view->list_pos;
1589 /* Computes "recommended" width for a fileview ruler. Returns the width. */
1590 static int
1591 get_fileview_ruler_width(view_t *view)
1592 {
1593 /* Size must correspond to the "worst case" of the last list item.
1594 * XXX: would be great to avoid modifying view for this. */
1595 int list_pos = view->list_pos;
1592 1596 view->list_pos = (view->list_rows == 0) ? 0 : (view->list_rows - 1); view->list_pos = (view->list_rows == 0) ? 0 : (view->list_rows - 1);
1593 1597
1594 expanded = expand_ruler_macros(view, cfg.ruler_format);
1595 len = strlen(expanded);
1598 char *expanded = expand_ruler_macros(view, cfg.ruler_format);
1599 int len = strlen(expanded);
1596 1600 free(expanded); free(expanded);
1597 1601
1598 1602 view->list_pos = list_pos; view->list_pos = list_pos;
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/vifm

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/vifm

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master