1 /* vifm 2 * Copyright (C) 2001 Ken Steen. 3 * Copyright (C) 2011 xaizek. 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 18 */ 19 20 #ifndef VIFM__UI__UI_H__ 21 #define VIFM__UI__UI_H__ 22 23 #include <sys/types.h> /* ino_t */ 24 25 #include <curses.h> 26 #include <regex.h> /* regex_t */ 27 28 #include <stddef.h> /* size_t wchar_t */ 29 #include <stdint.h> /* uint64_t uint32_t */ 30 #include <stdlib.h> /* mode_t */ 31 #include <time.h> /* time_t */ 32 #include <wchar.h> /* wint_t */ 33 34 #include "../compat/fs_limits.h" 35 #include "../compat/pthread.h" 36 #include "../utils/filter.h" 37 #include "../utils/fswatch.h" 38 #include "../utils/test_helpers.h" 39 #include "../marks.h" 40 #include "../status.h" 41 #include "../types.h" 42 #include "color_scheme.h" 43 #include "colors.h" 44 45 #define SORT_WIN_WIDTH 32 46 47 /* Width of the input window (located to the left of the ruler). */ 48 #define INPUT_WIN_WIDTH 6 49 50 /* Minimal width of the position window (located in the right corner of status 51 * line). */ 52 #define POS_WIN_MIN_WIDTH 13 53 54 /* Menus don't look like menus as all if height is less than 5. */ 55 #define MIN_TERM_HEIGHT 5 56 /* There is a lower limit on statusbar width. */ 57 #define MIN_TERM_WIDTH (INPUT_WIN_WIDTH + 1 + POS_WIN_MIN_WIDTH) 58 59 /* Width of the ruler and input windows. */ 60 #define FIELDS_WIDTH() (INPUT_WIN_WIDTH + getmaxx(ruler_win)) 61 62 /* New values should be added at the end of enumeration to do not brake sort 63 * settings stored in vifminfo files. Also SK_LAST and SK_COUNT should be 64 * updated accordingly. */ 65 typedef enum 66 { 67 SK_BY_EXTENSION = 1, /* Extension of files and directories. */ 68 SK_BY_NAME, /* Name (including extension). */ 69 #ifndef _WIN32 70 SK_BY_GROUP_ID, /* Group id. */ 71 SK_BY_GROUP_NAME, /* Group name. */ 72 SK_BY_MODE, /* File mode (file type + permissions) in octal. */ 73 SK_BY_OWNER_ID, /* Owner id. */ 74 SK_BY_OWNER_NAME, /* Owner name. */ 75 #endif 76 SK_BY_SIZE, /* Size. */ 77 SK_BY_TIME_ACCESSED, /* Time accessed (e.g. read, executed). */ 78 SK_BY_TIME_CHANGED, /* Time changed (changes in metadata, e.g. mode). */ 79 SK_BY_TIME_MODIFIED, /* Time modified (when file contents is changed). */ 80 SK_BY_INAME, /* Name (including extension, ignores case). */ 81 #ifndef _WIN32 82 SK_BY_PERMISSIONS, /* Permissions string. */ 83 #endif 84 SK_BY_DIR, /* Directory grouping (directory < file). */ 85 SK_BY_TYPE, /* File type (dir/reg/exe/link/char/block/sock/fifo). */ 86 SK_BY_FILEEXT, /* Extension of files only. */ 87 SK_BY_NITEMS, /* Number of items in a directory (zero for files). */ 88 SK_BY_GROUPS, /* Groups extracted via regexps from 'sortgroups'. */ 89 #ifndef _WIN32 90 SK_BY_NLINKS, /* Number of hard links. */ 91 #endif 92 SK_BY_TARGET, /* Symbolic link target (empty for other file types). */ 93 #ifndef _WIN32 94 SK_BY_INODE, /* Inode number. */ 95 #endif 96 /* New elements *must* be added here to keep values stored in existing 97 * vifminfo files valid. Don't forget to update SK_LAST below. */ 98 } 99 SortingKey; 100 101 enum 102 { 103 /* Default sort key. */ 104 #ifndef _WIN32 105 SK_DEFAULT = SK_BY_NAME, 106 #else 107 SK_DEFAULT = SK_BY_INAME, 108 #endif 109 110 /* Value of the last sort option. */ 111 #ifndef _WIN32 112 SK_LAST = SK_BY_INODE, 113 #else 114 SK_LAST = SK_BY_TARGET, 115 #endif 116 117 /* Number of sort options. */ 118 SK_COUNT = SK_LAST, 119 120 /* Special value to use for unset options. */ 121 SK_NONE = SK_LAST + 1, 122 123 /* Defined here to do not add it to sorting keys. */ 124 /* Id ordering. */ 125 SK_BY_ID = SK_NONE + 1, 126 /* Displaying only root of file name. */ 127 SK_BY_ROOT, 128 /* Displaying only root of file names for entries that aren't directories or 129 * symbolic links to directories. */ 130 SK_BY_FILEROOT, 131 132 /* Total number of SK_*, including those missing from sorting keys and other 133 * counts. */ 134 SK_TOTAL 135 }; 136 137 /* Type of file numbering. */ 138 typedef enum 139 { 140 NT_NONE = 0x00, /* Displaying of file numbers is disabled. */ 141 NT_SEQ = 0x01, /* Number are displayed as is (sequentially). */ 142 NT_REL = 0x02, /* Relative numbers are used for all items. */ 143 NT_MIX = NT_SEQ | NT_REL, /* All numbers are relative except for current. */ 144 } 145 NumberingType; 146 147 /* Variants of custom view. */ 148 typedef enum 149 { 150 CV_REGULAR, /* Sorted list of files. */ 151 CV_VERY, /* No initial sorting of file list is enforced. */ 152 CV_TREE, /* Files of a file system sub-tree. */ 153 CV_CUSTOM_TREE, /* Selected files of a file system sub-tree. */ 154 CV_COMPARE, /* Directory comparison pane. */ 155 CV_DIFF, /* One of two directory comparison panes. */ 156 } 157 CVType; 158 159 /* Type of file comparison. */ 160 typedef enum 161 { 162 CT_NAME, /* Compare just names. */ 163 CT_SIZE, /* Compare file sizes. */ 164 CT_CONTENTS, /* Compare file contents by combining size and hash. */ 165 } 166 CompareType; 167 168 /* Type of scheduled view update event. */ 169 typedef enum 170 { 171 UUE_NONE, /* No even scheduled at the time of request. */ 172 UUE_REDRAW, /* View redraw. */ 173 UUE_RELOAD, /* View reload with saving selection and cursor. */ 174 } 175 UiUpdateEvent; 176 177 /* Defines the way entry name should be formatted. */ 178 typedef enum 179 { 180 NF_NONE, /* No formatting at all. */ 181 NF_ROOT, /* Exclude extension and decorate the rest. */ 182 NF_FULL /* Decorate the whole name. */ 183 } 184 NameFormat; 185 186 /* Single entry of directory history. */ 187 typedef struct 188 { 189 char *dir; /* Directory path. */ 190 char *file; /* File name. */ 191 time_t timestamp; /* Time of storing this entry persistently. */ 192 int rel_pos; /* Cursor position from the top. */ 193 } 194 history_t; 195 196 /* Enable forward declaration of dir_entry_t. */ 197 typedef struct dir_entry_t dir_entry_t; 198 /* Description of a single directory entry. */ 199 struct dir_entry_t 200 { 201 char *name; /* File name. */ 202 char *origin; /* Location where this file comes from. Points to 203 view::curr_dir for non-cv views, otherwise allocated on 204 a heap. */ 205 uint64_t size; /* File size in bytes. */ 206 #ifndef _WIN32 207 uid_t uid; /* Owning user id. */ 208 gid_t gid; /* Owning group id. */ 209 mode_t mode; /* Mode of the file. */ 210 ino_t inode; /* Inode number. */ 211 #else 212 uint32_t attrs; /* Attributes of the file. */ 213 #endif 214 time_t mtime; /* Modification time. */ 215 time_t atime; /* Access time. */ 216 time_t ctime; /* Creation time. */ 217 int nlinks; /* Number of hard links to the entry. */ 218 219 int id; /* File uniqueness identifier on comparison. */ 220 221 int tag; /* Used to hold temporary data associated with the item, 222 e.g. by sorting comparer to perform stable sort or item 223 mapping during tree filtering. */ 224 225 int hi_num; /* File highlighting parameters cache. Initially -1. 226 INT_MAX signifies absence of a match. */ 227 int name_dec_num; /* File decoration parameters cache (initially -1). The 228 value is shifted by one, 0 means type decoration. */ 229 230 int child_count; /* Number of child entries (all, not just direct). */ 231 int child_pos; /* Position of this entry in among children of its parent. 232 Zero for top-level entries. */ 233 234 int search_match; /* Non-zero if the item matches last search. Equals to 235 search match number (top to bottom order). */ 236 short int match_left; /* Starting position of search match. */ 237 short int match_right; /* Ending position of search match. */ 238 239 FileType type : 4; /* File type. */ 240 unsigned int selected : 1; /* Whether file is selected. */ 241 unsigned int was_selected : 1; /* Previous selection state for Visual mode. */ 242 unsigned int marked : 1; /* Whether file should be processed. */ 243 unsigned int temporary : 1; /* Whether this is temporary node. */ 244 unsigned int dir_link : 1; /* Whether this is symlink to a directory. */ 245 }; 246 247 /* List of entries bundled with its size. */ 248 typedef struct 249 { 250 dir_entry_t *entries; /* List of entries. */ 251 int nentries; /* Number entries in the list. */ 252 } 253 entries_t; 254 255 /* Data related to custom filling. */ 256 struct cv_data_t 257 { 258 /* Type of the custom view. */ 259 CVType type; 260 261 /* Additional data about CV_DIFF type. */ 262 CompareType diff_cmp_type; /* Type of comparison. */ 263 int diff_path_group; /* Whether entries are grouped by paths. */ 264 265 /* This is temporary storage for custom list entries used during its 266 * construction. */ 267 dir_entry_t *entries; /* File entries. */ 268 int entry_count; /* Number of file entries. */ 269 270 /* Title of the custom view being constructed. Discarded if finishing 271 * fails. */ 272 char *next_title; 273 274 /* Directory we were in before custom view activation. */ 275 char *orig_dir; 276 /* Title for the custom view. */ 277 char *title; 278 279 /* Previous sorting value, before unsorted custom view was loaded. */ 280 signed char sort[SK_COUNT]; 281 282 /* List of paths that should be ignored (including all nested paths). Used 283 * by tree-view. */ 284 struct trie_t *excluded_paths; 285 286 /* Names of files in custom view while it's being composed. Used for 287 * duplicate elimination during construction of custom list. */ 288 struct trie_t *paths_cache; 289 }; 290 291 /* Various parameters related to local filter. */ 292 struct local_filter_t 293 { 294 /* Original list of custom entries saved because otherwise we lose it. */ 295 dir_entry_t *entries; /* File entries. */ 296 int entry_count; /* Number of file entries. */ 297 298 /* Local filename filter. */ 299 filter_t filter; 300 /* Whether interactive filtering in progress. */ 301 int in_progress; 302 /* Removed value of local filename filter. Stored for restore operation. */ 303 char *prev; 304 /* Temporary storage for local filename filter, when its overwritten. */ 305 char *saved; 306 307 /* Unfiltered file entries. */ 308 dir_entry_t *unfiltered; 309 /* Number of unfiltered entries. */ 310 size_t unfiltered_count; 311 /* Number of entries filtered in other ways. */ 312 size_t prefiltered_count; 313 314 /* List of previous cursor positions in the unfiltered array. */ 315 int *poshist; 316 /* Number of elements in the poshist field. */ 317 size_t poshist_len; 318 }; 319 320 /* Cached file list coupled with a watcher. */ 321 typedef struct 322 { 323 fswatch_t *watch; /* Watcher for the path. */ 324 char *dir; /* Path to watched directory. */ 325 entries_t entries; /* Cached list of entries. */ 326 } 327 cached_entries_t; 328 329 /* Enable forward declaration of view_t. */ 330 typedef struct view_t view_t; 331 /* State of a pane. */ 332 struct view_t 333 { 334 WINDOW *win; 335 WINDOW *title; 336 337 /* Directory we're currently in. */ 338 char curr_dir[PATH_MAX + 1]; 339 340 /* Data related to custom filling. */ 341 struct cv_data_t custom; 342 343 /* Various parameters related to local filter. */ 344 struct local_filter_t local_filter; 345 346 /* Non-zero if miller columns view is enabled. */ 347 int miller_view, miller_view_g; 348 /* Proportions of columns. */ 349 int miller_ratios[3], miller_ratios_g[3]; 350 /* Whether right column should also preview files. */ 351 int miller_preview_files, miller_preview_files_g; 352 /* Caches of file lists for miller mode. */ 353 cached_entries_t left_column; 354 cached_entries_t right_column; 355 356 fswatch_t *watch; /* Monitor that checks for directory changes. */ 357 char *watched_dir; /* Path for which the monitor was created. */ 358 359 char *last_dir; /* Location visited by the view before the current one. */ 360 361 /* Number of files that match current search pattern. */ 362 int matches; 363 /* Last used search pattern, empty if none. */ 364 char last_search[NAME_MAX + 1]; 365 366 int hide_dot, hide_dot_g; /* Whether dot files are hidden. */ 367 int prev_invert; 368 int invert; /* whether to invert the filename pattern */ 369 int curr_line; /* current line # of the window */ 370 int top_line; /* # of the list position that is the top line in window */ 371 int list_pos; /* actual position in the file list */ 372 int list_rows; /* size of the file list */ 373 int window_rows; /* Number of rows in the window. */ 374 int window_cols; /* Number of columns in the window. */ 375 int filtered; /* number of files filtered out and not shown in list */ 376 int selected_files; /* Number of currently selected files. */ 377 dir_entry_t *dir_entry; /* Must be handled via dynarray unit. */ 378 379 /* Last position that was displayed on the screen. */ 380 char *last_curr_file; /* To account for file replacement. */ 381 int last_seen_pos; /* To account for movement. */ 382 int last_curr_line; /* To account for scrolling. */ 383 384 int nsaved_selection; /* Number of items in saved_selection. */ 385 char **saved_selection; /* Names of selected files. */ 386 387 /* Files were marked for processing, but haven't been processed yet. */ 388 int pending_marking; 389 390 int explore_mode; /* Whether this view is used for file exploring. */ 391 struct modview_info_t *vi; /* State of explore view (NULL initially). */ 392 393 /* Filter which is controlled by user. */ 394 struct matcher_t *manual_filter; 395 /* Stores previous raw value of the manual_filter to make filter restoring 396 * possible. Always not NULL. */ 397 char *prev_manual_filter; 398 399 /* Filter which is controlled automatically and never filled by user. */ 400 filter_t auto_filter; 401 /* Stores previous raw value of the auto_filter to make filter restoring 402 * possible. Not NULL. */ 403 char *prev_auto_filter; 404 405 mark_t special_marks[NUM_SPECIAL_MARKS]; /* View-specific marks. */ 406 407 /* List of sorting keys. */ 408 signed char sort[SK_COUNT], sort_g[SK_COUNT]; 409 /* Sorting groups (comma-separated list of regular expressions). */ 410 char *sort_groups, *sort_groups_g; 411 /* Primary group in compiled form. */ 412 regex_t primary_group; 413 414 int history_num; /* Number of used history elements. */ 415 int history_pos; /* Current position in history. */ 416 history_t *history; /* Directory history itself (oldest to newest). */ 417 418 int local_cs; /* Whether directory-specific color scheme is in use. */ 419 col_scheme_t cs; /* Storage of local (tree-specific) color scheme. */ 420 421 /* Handle for column_view unit. Contains view columns configuration even when 422 * 'lsview' is on. */ 423 struct columns_t *columns; 424 /* Format string that specifies view columns. */ 425 char *view_columns, *view_columns_g; 426 427 /* Preview command to use instead of programs configured via :fileviewer. */ 428 char *preview_prg, *preview_prg_g; 429 430 /* ls-like view related fields. */ 431 int ls_view, ls_view_g; /* Non-zero if ls-like view is enabled. */ 432 int ls_transposed, ls_transposed_g; /* Non-zero for transposed ls-view. */ 433 size_t max_filename_width; /* Maximum filename width (length in character 434 * positions on the screen) among all entries of 435 * the file list. Zero if not calculated. */ 436 int column_count; /* Number of columns in the view, used for list view. */ 437 int run_size; /* Length of run in leading direction (neighbourhood), 438 * number of elements in a stride. Greater than 1 in 439 * ls-like/grid view. */ 440 int window_cells; /* Max number of files that can be displayed. */ 441 442 /* Whether and how line numbers are displayed. */ 443 NumberingType num_type, num_type_g; 444 /* Min number of characters reserved for number field. */ 445 int num_width, num_width_g; 446 int real_num_width; /* Real character count reserved for number field. */ 447 448 int need_redraw; /* Whether view should be redrawn. */ 449 int need_reload; /* Whether view should be reloaded. */ 450 pthread_mutex_t *timestamps_mutex; /* Protects access to above variables. 451 This is a pointer, because mutexes 452 shouldn't be copied. */ 453 454 int on_slow_fs; /* Whether current directory has access penalties. */ 455 int has_dups; /* Whether current directory has duplicated file entries (FS 456 issue). */ 457 458 int location_changed; /* Whether location was recently changed. */ 459 460 int displays_graphics; /* Whether window of the view contains graphics. */ 461 }; 462 463 extern view_t lwin; 464 extern view_t rwin; 465 extern view_t *other_view; 466 extern view_t *curr_view; 467 468 extern WINDOW *status_bar; 469 extern WINDOW *stat_win; 470 extern WINDOW *job_bar; 471 extern WINDOW *ruler_win; 472 extern WINDOW *input_win; 473 extern WINDOW *menu_win; 474 extern WINDOW *sort_win; 475 extern WINDOW *change_win; 476 extern WINDOW *error_win; 477 478 /* Updates the ruler with information from the view (possibly lazily). */ 479 void ui_ruler_update(view_t *view, int lazy_redraw); 480 481 /* Sets text to be displayed on the ruler. Real window update is postponed for 482 * efficiency reasons. */ 483 void ui_ruler_set(const char val[]); 484 485 /* Checks whether terminal is operational and has at least minimal 486 * dimensions. Might terminate application on unavailable terminal. Updates 487 * term_state in status structure. */ 488 void ui_update_term_state(void); 489 490 /* Checks whether given character was pressed discarding any other characters 491 * from the input stream. */ 492 int ui_char_pressed(wint_t c); 493 494 /* Reads buffered input until it's empty. */ 495 void ui_drain_input(void); 496 497 int setup_ncurses_interface(void); 498 499 /* Closes current tab if it's not the last one, closes whole application 500 * otherwise. Might also fail if background tasks are present and user chooses 501 * not to stop them. */ 502 void ui_quit(int write_info, int force); 503 504 /* Checks whether custom view of specified type is unsorted. Returns non-zero 505 * if so, otherwise zero is returned. */ 506 int cv_unsorted(CVType type); 507 508 /* Checks whether custom view of specified type is a compare or diff view. 509 * Returns non-zero if so, otherwise zero is returned. */ 510 int cv_compare(CVType type); 511 512 /* Checks whether custom view of specified type is a tree view. Returns 513 * non-zero if so, otherwise zero is returned. */ 514 int cv_tree(CVType type); 515 516 /* Resizes all windows according to current screen size and TUI 517 * configuration. */ 518 void ui_resize_all(void); 519 520 /* Redraws whole screen with possible reloading of file lists (depends on 521 * argument). */ 522 void update_screen(UpdateType update_kind); 523 524 /* Swaps curr_view and other_view pointers (active and inactive panes). Also 525 * updates things (including UI) that are bound to views. */ 526 void change_window(void); 527 528 /* Swaps curr_view and other_view pointers. */ 529 void swap_view_roles(void); 530 531 /* Forcibly updates all windows. */ 532 void update_all_windows(void); 533 534 /* Touches all windows, actual update can be performed later. */ 535 void touch_all_windows(void); 536 537 void update_input_bar(const wchar_t *str); 538 539 void clear_num_window(void); 540 541 /* Displays progress on the status bar, not updating it frequently. msg can't 542 * be NULL. period - how often status bar should be updated. If period equals 543 * 0 inner counter is reset, do this on start of operation. For period <= 1, 544 * its absolute value is used and count is not printed. */ 545 void show_progress(const char msg[], int period); 546 547 void redraw_lists(void); 548 549 /* Forces immediate update of attributes for most of windows. */ 550 void update_attributes(void); 551 552 /* Refreshes the window, should be used instead of wrefresh(). */ 553 #pragma GCC poison wrefresh 554 void ui_refresh_win(WINDOW *win); 555 556 /* Prints str in current window position. */ 557 void wprint(WINDOW *win, const char str[]); 558 559 /* Prints str in current window position with specified line attributes. Value 560 * of attrs_xors is xored with attributes of line_attrs. */ 561 void wprinta(WINDOW *win, const char str[], const cchar_t *line_attrs, 562 int attrs_xors); 563 564 /* Performs resizing of some of TUI elements for menu like modes. Returns zero 565 * on success, and non-zero otherwise. */ 566 int resize_for_menu_like(void); 567 568 /* Performs updates of layout for menu like modes. */ 569 void ui_setup_for_menu_like(void); 570 571 /* Performs real pane redraw in the TUI and maybe some related operations. */ 572 void refresh_view_win(view_t *view); 573 574 /* Layouts the view in correct corner with correct relative position 575 * (horizontally/vertically, left-top/right-bottom). */ 576 void move_window(view_t *view, int horizontally, int first); 577 578 /* Swaps current and other views. */ 579 void switch_panes(void); 580 581 /* Swaps data fields of two panes. Doesn't correct origins of directory 582 * entries. */ 583 void ui_swap_view_data(view_t *left, view_t *right); 584 585 /* Setups view to the the curr_view. Saving previous state in supplied buffers. 586 * Use ui_view_unpick() to revert the effect. */ 587 void ui_view_pick(view_t *view, view_t **old_curr, view_t **old_other); 588 589 /* Restores what has been done by ui_view_pick(). */ 590 void ui_view_unpick(view_t *view, view_t *old_curr, view_t *old_other); 591 592 /* Switches to other pane, ignoring state of the preview and entering view mode 593 * in case the other pane has explore mode active. */ 594 void go_to_other_pane(void); 595 596 /* Splits windows according to the value of orientation. */ 597 void split_view(SPLIT orientation); 598 599 /* Switches view to one-window mode. */ 600 void only(void); 601 602 /* Moves window splitter by specified amount of positions multiplied by the 603 * given factor. */ 604 void move_splitter(int by, int fact); 605 606 /* Sets size of the view to specified value. */ 607 void ui_view_resize(view_t *view, int to); 608 609 /* File name formatter which takes 'classify' option into account and applies 610 * type dependent name decorations if requested. */ 611 void format_entry_name(const dir_entry_t *entry, NameFormat fmt, size_t buf_len, 612 char buf[]); 613 614 /* Retrieves decorations for file entry. Sets *prefix and *suffix to strings 615 * stored in global configuration. */ 616 void ui_get_decors(const dir_entry_t *entry, const char **prefix, 617 const char **suffix); 618 619 /* Resets cached indexes for name-dependent type_decs. */ 620 void ui_view_reset_decor_cache(const view_t *view); 621 622 /* Moves cursor to position specified by coordinates checking result of the 623 * movement. */ 624 void checked_wmove(WINDOW *win, int y, int x); 625 626 /* Displays "Terminal is too small" kind of message instead of UI. */ 627 void ui_display_too_small_term_msg(void); 628 629 /* Notifies TUI module about updated window of the view. */ 630 void ui_view_win_changed(view_t *view); 631 632 /* Resets selection of the view and reloads it preserving cursor position. */ 633 void ui_view_reset_selection_and_reload(view_t *view); 634 635 /* Resets search highlighting of the view and schedules reload. */ 636 void ui_view_reset_search_highlight(view_t *view); 637 638 /* Reloads visible lists of files preserving current position of cursor. */ 639 void ui_views_reload_visible_filelists(void); 640 641 /* Reloads lists of files preserving current position of cursor. */ 642 void ui_views_reload_filelists(void); 643 644 /* Updates title of the views. */ 645 void ui_views_update_titles(void); 646 647 /* Updates title of the view. */ 648 void ui_view_title_update(view_t *view); 649 650 /* Looks for the given key in sort option. Returns non-zero when found, 651 * otherwise zero is returned. */ 652 int ui_view_sort_list_contains(const signed char sort[SK_COUNT], char key); 653 654 /* Ensures that list of sorting keys is sensible (i.e. contains either "name" or 655 * "iname" for views, except for unsorted custom view). */ 656 void ui_view_sort_list_ensure_well_formed(view_t *view, 657 signed char sort_keys[]); 658 659 /* Picks sort array for the view taking custom view into account. sort should 660 * point to sorting array preferred by default. Returns pointer to the 661 * array. */ 662 signed char * ui_view_sort_list_get(const view_t *view, 663 const signed char sort[]); 664 665 /* Checks whether file numbers should be displayed for the view. Returns 666 * non-zero if so, otherwise zero is returned. */ 667 int ui_view_displays_numbers(const view_t *view); 668 669 /* Checks whether view is visible on the screen. Returns non-zero if so, 670 * otherwise zero is returned. */ 671 int ui_view_is_visible(const view_t *view); 672 673 /* Checks whether view displays column view. Returns non-zero if so, otherwise 674 * zero is returned. */ 675 int ui_view_displays_columns(const view_t *view); 676 677 /* Gets width of part of the view that is available for file list. Returns the 678 * width. */ 679 int ui_view_available_width(const view_t *view); 680 681 /* Retrieves width reserved for something to the left of file list. Returns the 682 * width. */ 683 int ui_view_left_reserved(const view_t *view); 684 685 /* Retrieves width reserved for something to the right of file list. Returns 686 * the width. */ 687 int ui_view_right_reserved(const view_t *view); 688 689 /* Retrieves column number at which quickview content should be displayed. 690 * Returns the number. */ 691 int ui_qv_left(const view_t *view); 692 693 /* Retrieves line number at which quickview content should be displayed. 694 * Returns the number. */ 695 int ui_qv_top(const view_t *view); 696 697 /* Retrieves height of quickview area. Returns the height. */ 698 int ui_qv_height(const view_t *view); 699 700 /* Retrieves width of quickview area. Returns the width. */ 701 int ui_qv_width(const view_t *view); 702 703 /* If active preview needs special cleanup (i.e., simply redrawing a window 704 * isn't enough. */ 705 void ui_qv_cleanup_if_needed(void); 706 707 /* Invalidates views-specific knowledge about given color scheme. */ 708 void ui_invalidate_cs(const col_scheme_t *cs); 709 710 /* Gets color scheme that corresponds to the view. Returns pointer to the color 711 * scheme. */ 712 const col_scheme_t * ui_view_get_cs(const view_t *view); 713 714 /* Erases view window by filling it with the background color. */ 715 void ui_view_erase(view_t *view, int use_global_cs); 716 717 /* Figures out base color for the pane. Returns the color. */ 718 col_attr_t ui_get_win_color(const view_t *view, const col_scheme_t *cs); 719 720 /* Checks whether custom view type of specified view is unsorted. It doesn't 721 * need the view to be custom, checks just the type. Returns non-zero if so, 722 * otherwise zero is returned. */ 723 int ui_view_unsorted(const view_t *view); 724 725 /* Shuts down UI making it possible to use terminal (either after vifm is closed 726 * or when terminal might be used by another application that vifm runs). */ 727 void ui_shutdown(void); 728 729 /* Temporarily shuts down UI until a key is pressed. */ 730 void ui_pause(void); 731 732 /* Sets background color of the window. Allocates pair if passed in pair number 733 * is negative. When pair is passed in, only attribute part of the col 734 * parameter is used. */ 735 void ui_set_bg(WINDOW *win, const col_attr_t *col, int pair); 736 737 /* Sets current color of the window. Allocates pair if passed in pair number is 738 * negative. When pair is passed in, only attribute part of the col parameter 739 * is used. */ 740 void ui_set_attr(WINDOW *win, const col_attr_t *col, int pair); 741 742 /* Clears attribute of the window. */ 743 void ui_drop_attr(WINDOW *win); 744 745 struct strlist_t; 746 747 /* Outputs lines into terminal circumventing curses. Positions cursor at the 748 * specified point on the window beforehand. */ 749 void ui_pass_through(const struct strlist_t *lines, WINDOW *win, int x, int y); 750 751 /* View update scheduling. */ 752 753 /* Schedules redraw of the view for the future. Doesn't perform any actual 754 * update. */ 755 void ui_view_schedule_redraw(view_t *view); 756 757 /* Schedules reload of the view for the future. Doesn't perform any actual 758 * work. */ 759 void ui_view_schedule_reload(view_t *view); 760 761 /* Clears previously scheduled redraw request of the view, if any. */ 762 void ui_view_redrawn(view_t *view); 763 764 /* Checks for scheduled update and marks it as fulfilled. Returns kind of 765 * scheduled event. */ 766 UiUpdateEvent ui_view_query_scheduled_event(view_t *view); 767 768 TSTATIC_DEFS( 769 /* Information for formatting tab title. */ 770 typedef struct 771 { 772 char *name; /* Tab name. */ 773 char *num; /* Tab number. */ 774 char *escaped_view_title; /* Auto-formatted title. */ 775 char *escaped_path; /* Current path (could be a file path). */ 776 char *cv_title; /* Prefix of custom view. */ 777 int tree; /* Whether in tree mode. */ 778 int current; /* Whether it's a current tab. */ 779 } 780 tab_title_info_t; 781 782 struct cline_t; 783 struct tab_info_t; 784 typedef char * (*path_func)(const char[]); 785 tab_title_info_t make_tab_title_info(const struct tab_info_t *tab_info, 786 path_func pf, int tab_num, int current_tab); 787 void dispose_tab_title_info(tab_title_info_t *title_info); 788 struct cline_t make_tab_title(const tab_title_info_t *title_info); 789 ) 790 791 #endif /* VIFM__UI__UI_H__ */ 792 793 /* vim: set tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab cinoptions-=(0 : */ 794 /* vim: set cinoptions+=t0 filetype=c : */ 795