Skip to content

Commit

Permalink
Merge branch 'add-previewoptions-option'
Browse files Browse the repository at this point in the history
Add 'previewoptions' option to allow tweaking graphics preview a bit.

Thanks to Joshua Jensch (a.k.a., patroclos) and flux242.

Add *.flex and *.ypp to Default-256 color scheme.

Don't separate tags with / in Vim documentation.

Fix quickview not being redrawn after leaving File Info dialog or more
mode.
  • Loading branch information
xaizek committed Dec 7, 2020
2 parents 47d7946 + a40eed2 commit 1593e20
Show file tree
Hide file tree
Showing 19 changed files with 217 additions and 51 deletions.
6 changes: 6 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
Added a and A view mode keys that switch to next and previous viewer of
current file correspondingly. Thanks to j-xella.

Added 'previewoptions' option to allow tweaking graphics preview a bit.
Thanks to Joshua Jensch (a.k.a., patroclos) and flux242.

Made :VifmCs of the plugin fail when 'termguicolors' produces a 24-bit color
value. Thanks to AtomToast.

Expand Down Expand Up @@ -51,6 +54,9 @@

Fixed presence of %q macro causing second round of macro expansion.

Fixed quickview not being redrawn after leaving File Info dialog or more
mode.

0.11-beta to 0.11 (2020-09-24)

Recommend against setting 'shellcmdflag' to "-ic" value.
Expand Down
2 changes: 2 additions & 0 deletions THANKS
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ Fang (peromage)
filterfalse
Flaviu Tamas (flaviut)
Florian Baumann (derflob)
flux242
fogine
gammaray
gcmt
Expand Down Expand Up @@ -103,6 +104,7 @@ John Shea (coachshea)
Jose Riha (jose1711)
Joseph LP (ootput)
Josh Wainwright (joshaw)
Joshua Jensch (patroclos)
jsmith51 (metal.lunchbox)
kalterfive
kangshugang
Expand Down
4 changes: 2 additions & 2 deletions data/colors/Default-256.vifm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

" This is Vifm's default color scheme for terminals that support 256 colors.
"
" This file last updated: 3 September, 2020
" This file last updated: 4 December, 2020

highlight clear

Expand Down Expand Up @@ -88,5 +88,5 @@ highlight {*.sh,*.bash,*.zsh,*.bat,*.btm,*.cmd,*.com,*.dll,*.exe,*.run,*.msu,
highlight {*.patch,*.diff,*.py,*.cpp,*.hpp,*.mk,*.c,*.h,*.cpp,*.hpp,*.cc,*.hs,
\*.php,*.lua,*.vim,*.vifm,*.asm,*.s,*.java,*.cxx,*.c++,*.go,
\*.pl,*.pm,*.t,*.cs,*.asp,*.dart,*.js,*.rb,*.scala,*.ts,*.coffee,
\*.ml,*.mli,*.rs,*.sql,*.qml,vifmrc,vimrc,.vimrc}
\*.ml,*.mli,*.rs,*.sql,*.qml,vifmrc,vimrc,.vimrc,*.flex,*.ypp}
\ cterm=none ctermfg=193 ctermbg=default
24 changes: 22 additions & 2 deletions data/man/vifm.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH VIFM 1 "November 28, 2020" "vifm 0.11"
.TH VIFM 1 "December 7, 2020" "vifm 0.11"
.\" ---------------------------------------------------------------------------
.SH NAME
.\" ---------------------------------------------------------------------------
Expand Down Expand Up @@ -1027,7 +1027,7 @@ scroll to the beginning of the file (or N percent into file).
.TP
.BI v
invoke an editor to edit the current file being viewed. The command for editing
is taken from the 'vicmd'/'vixcmd' option value and extended with middle line
is taken from the 'vicmd' or 'vixcmd' option value and extended with middle line
number prepended by a plus sign and name of the current file.
.LP
All "Ctrl-W x" keys work the same was as in Normal mode. Active mode is
Expand Down Expand Up @@ -4245,6 +4245,26 @@ scope: local
.br
Minimal number of characters for line number field.
.TP
.BI "'previewoptions'"
type: string list
.br
default: "graphicsdelay:50000"
.br

Tweaks how previewing is done (in quick view, miller view's column and
view mode).

item default meaning
graphicsdelay:num 0 delay before drawing graphics (microseconds)
hardgraphicsclear unset redraw screen to get rid of graphics

graphicsdelay is needed if terminal requires some timeout before it can
draw graphics (otherwise it gets lost).

hardgraphicsclear seems to be necessary to get rid of sixel graphics in some
terminals, where it otherwise lingers. This can cause flicker on the screen
due to erasure followed by redrawing.
.TP
.BI "'previewprg'"
type: string
.br
Expand Down
25 changes: 23 additions & 2 deletions data/vim/doc/app/vifm-app.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*vifm-app.txt* For Vifm version 0.11 Last change: 2020 Nov 28
*vifm-app.txt* For Vifm version 0.11 Last change: 2020 Dec 7

Email for bugs and suggestions: <xaizek@posteo.net>

Expand Down Expand Up @@ -907,7 +907,7 @@ i *vifm-q_i*

v *vifm-q_v*
invoke an editor to edit the current file being viewed. The command for
editing is taken from the |vifm-'vicmd'|/|vifm-'vixcmd'| option value and
editing is taken from the |vifm-'vicmd'| or |vifm-'vixcmd'| option value and
extended with middle line number prepended by a plus sign and name of the
current file.

Expand Down Expand Up @@ -3559,6 +3559,27 @@ scope: local

Minimal number of characters for line number field.

*vifm-'previewoptions'*
previewoptions
type: string list
default: "graphicsdelay:50000"

Tweaks how previewing is done (in quick view, miller view's column and
view mode).

item default meaning ~
graphicsdelay:num 0 delay before drawing graphics (microseconds)
hardgraphicsclear unset redraw screen to get rid of graphics

graphicsdelay is needed if terminal requires some timeout before it can
draw graphics (otherwise it gets lost).

hardgraphicsclear seems to be necessary to get rid of sixel graphics in some
terminals, where it otherwise lingers. This can cause flicker on the screen
due to erasure followed by redrawing.

Default value is used when item is missing from the option.

*vifm-'previewprg'*
previewprg
type: string
Expand Down
17 changes: 9 additions & 8 deletions data/vim/syntax/vifm.vim
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
" vifm syntax file
" Maintainer: xaizek <xaizek@posteo.net>
" Last Change: October 6, 2020
" Last Change: December 6, 2020
" Inspired By: Vim syntax file by Dr. Charles E. Campbell, Jr.

if exists('b:current_syntax')
Expand Down Expand Up @@ -141,13 +141,14 @@ syntax keyword vifmOption contained aproposprg autochpos caseoptions cdpath cd
\ followlinks fusehome gdefault grepprg histcursor history hi hlsearch hls
\ iec ignorecase ic iooptions incsearch is laststatus lines locateprg ls
\ lsoptions lsview mediaprg milleroptions millerview mintimeoutlen number nu
\ numberwidth nuw previewprg quickview relativenumber rnu rulerformat ruf
\ runexec scrollbind scb scrolloff sessionoptions ssop so sort sortgroups
\ sortorder sortnumbers shell sh shellflagcmd shcf shortmess shm showtabline
\ stal sizefmt slowfs smartcase scs statusline stl suggestoptions syncregs
\ syscalls tablabel tabprefix tabscope tabstop tabsuffix timefmt timeoutlen
\ title tm trash trashdir ts tuioptions to undolevels ul vicmd viewcolumns
\ vifminfo vimhelp vixcmd wildmenu wmnu wildstyle wordchars wrap wrapscan ws
\ numberwidth nuw previewoptions previewprg quickview relativenumber rnu
\ rulerformat ruf runexec scrollbind scb scrolloff sessionoptions ssop so
\ sort sortgroups sortorder sortnumbers shell sh shellflagcmd shcf shortmess
\ shm showtabline stal sizefmt slowfs smartcase scs statusline stl
\ suggestoptions syncregs syscalls tablabel tabprefix tabscope tabstop
\ tabsuffix timefmt timeoutlen title tm trash trashdir ts tuioptions to
\ undolevels ul vicmd viewcolumns vifminfo vimhelp vixcmd wildmenu wmnu
\ wildstyle wordchars wrap wrapscan ws

" Disabled boolean options
syntax keyword vifmOption contained noautochpos nocf nochaselinks nodotfiles
Expand Down
3 changes: 3 additions & 0 deletions src/cfg/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ cfg_init(void)

cfg.chase_links = 0;

cfg.graphics_delay = 50000;
cfg.hard_graphics_clear = 0;

cfg.timeout_len = 1000;
cfg.min_timeout_len = 150;

Expand Down
5 changes: 5 additions & 0 deletions src/cfg/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,11 @@ typedef struct config_t
* link expanded). */
int chase_links;

/* Delay before redrawing graphics in microseconds. */
int graphics_delay;
/* Redraw screen to get rid of graphics. */
int hard_graphics_clear;

int timeout_len; /* Maximum period on waiting for the input. */
int min_timeout_len; /* Minimum period on waiting for the input. */

Expand Down
2 changes: 2 additions & 0 deletions src/cfg/info.c
Original file line number Diff line number Diff line change
Expand Up @@ -2242,6 +2242,8 @@ store_global_options(JSON_Object *root)
append_dstr(options, format_str("rulerformat=%s",
escape_spaces(cfg.ruler_format)));
append_dstr(options, format_str("%srunexec", cfg.auto_execute ? "" : "no"));
append_dstr(options, format_str("previewoptions=%s",
escape_spaces(vle_opts_get("previewoptions", OPT_GLOBAL))));
append_dstr(options, format_str("%sscrollbind", cfg.scroll_bind ? "" : "no"));
append_dstr(options, format_str("scrolloff=%d", cfg.scroll_off));
append_dstr(options, format_str("shell=%s", escape_spaces(cfg.shell)));
Expand Down
2 changes: 1 addition & 1 deletion src/cmd_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include <errno.h>
#include <signal.h>
#include <stddef.h> /* NULL size_t */
#include <stdio.h> /* pclose() popen() snprintf() */
#include <stdio.h> /* snprintf() */
#include <stdlib.h> /* EXIT_SUCCESS atoi() free() realloc() */
#include <string.h> /* strchr() strcmp() strcspn() strcasecmp() strcpy()
strdup() strlen() strrchr() */
Expand Down
16 changes: 1 addition & 15 deletions src/modes/file_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ static void cmd_ctrl_c(key_info_t key_info, keys_info_t *keys_info);
static void cmd_ctrl_l(key_info_t key_info, keys_info_t *keys_info);

static view_t *view;
static int was_redraw;

static keys_add_info_t builtin_cmds[] = {
{WK_C_c, {{&cmd_ctrl_c}, .descr = "hide file info"}},
Expand Down Expand Up @@ -103,8 +102,6 @@ modfinfo_enter(view_t *v)
view = v;
ui_setup_for_menu_like();
modfinfo_redraw();

was_redraw = 0;
}

void
Expand All @@ -117,16 +114,7 @@ static void
leave_file_info_mode(void)
{
vle_mode_set(NORMAL_MODE, VMT_PRIMARY);

if(was_redraw)
{
update_screen(UT_FULL);
}
else
{
ui_view_title_update(curr_view);
update_all_windows();
}
stats_redraw_later();
}

void
Expand Down Expand Up @@ -217,8 +205,6 @@ modfinfo_redraw(void)
wprint(menu_win, " File Information ");
ui_refresh_win(menu_win);
checked_wmove(menu_win, 2, 2);

was_redraw = 1;
}

/* Prints item prefixed with a label truncating the item if it's too long.
Expand Down
18 changes: 1 addition & 17 deletions src/modes/more.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ static void goto_vline(int line);
static void goto_vline_below(int by);
static void goto_vline_above(int by);

/* Whether UI was redrawn while this mode was active. */
static int was_redraw;

/* Text displayed by the mode. */
static char *text;
/* (first virtual line, screen width, offset in text) triples per real line. */
Expand Down Expand Up @@ -134,7 +131,6 @@ modmore_enter(const char txt[])
vle_mode_set(MORE_MODE, VMT_PRIMARY);

modmore_redraw();
was_redraw = 0;
}

void
Expand Down Expand Up @@ -186,15 +182,7 @@ leave_more_mode(void)
data = NULL;

vle_mode_set(NORMAL_MODE, VMT_PRIMARY);

if(was_redraw)
{
update_screen(UT_FULL);
}
else
{
update_all_windows();
}
stats_redraw_later();
}

void
Expand All @@ -213,8 +201,6 @@ modmore_redraw(void)

draw_all(get_text_beginning());
checked_wmove(menu_win, 0, 0);

was_redraw = 1;
}

/* Retrieves beginning of the text that should be displayed. Returns the
Expand Down Expand Up @@ -261,8 +247,6 @@ draw_all(const char text[])

/* Apply all changes. */
doupdate();

was_redraw = 1;
}

/* Leaves the mode. */
Expand Down
2 changes: 1 addition & 1 deletion src/modes/view.c
Original file line number Diff line number Diff line change
Expand Up @@ -1112,7 +1112,7 @@ get_view_data(modview_info_t *vi, const char file_to_view[])
{
/* Wait a bit to let terminal emulator do actual refresh (at least some of
* them need this). */
usleep(50000);
usleep(cfg.graphics_delay);
}

const char *error;
Expand Down

0 comments on commit 1593e20

Please sign in to comment.