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 9b93cfe5819ad0b52ab48c0e7cd0360cf453e2eb

Add `:messages clear` to clear message history
Thanks to qadzek.

See https://q2a.vifm.info/2199/misc-feedback
Author: xaizek
Author date (UTC): 2025-07-23 13:46
Committer name: xaizek
Committer date (UTC): 2025-07-23 14:51
Parent(s): 775e904bbd5d937ad970caae0b51101dc5d8d8d4
Signing key: 99DC5E4DB05F6BE2
Tree: 906af0f61f9406df693c3e2cd4649576aeb0affb
File Lines added Lines deleted
ChangeLog 3 0
data/man/vifm.1 4 1
data/vim/doc/app/vifm-app.txt 6 3
src/cmd_completion.c 11 0
src/cmd_completion.h 1 0
src/cmd_handlers.c 16 4
src/status.c 14 7
src/status.h 3 0
tests/commands/completion.c 10 0
tests/commands/misc.c 15 0
File ChangeLog changed (mode: 100644) (index 4763c7656..86b6bfd37)
18 18 Attempt to choose more than 1 item results in an error dialog. Thanks to Attempt to choose more than 1 item results in an error dialog. Thanks to
19 19 The Cyberduck. The Cyberduck.
20 20
21 Added `:messages clear` to clear the history of the most recent status bar
22 messages. Thanks to qadzek.
23
21 24 Updated utf8proc to v2.10.0. Updated utf8proc to v2.10.0.
22 25
23 26 Made documentation on which :commands can have comments a bit more Made documentation on which :commands can have comments a bit more
File data/man/vifm.1 changed (mode: 100644) (index c50c31ee7..8d386fd01)
1 .TH VIFM 1 "22 July 2025" "vifm 0.15"
1 .TH VIFM 1 "23 July 2025" "vifm 0.15"
2 2 .\" --------------------------------------------------------------------------- .\" ---------------------------------------------------------------------------
3 3 .SH NAME .SH NAME
4 4 .\" --------------------------------------------------------------------------- .\" ---------------------------------------------------------------------------
 
... ... See also 'mediaprg' option.
2702 2702 .BI ":mes[sages]" .BI ":mes[sages]"
2703 2703 shows previously given messages (up to 50). shows previously given messages (up to 50).
2704 2704 .TP .TP
2705 .BI ":mes[sages] clear"
2706 clear the history of the most recent status bar messages.
2707 .TP
2705 2708 .BI " :mkdir" .BI " :mkdir"
2706 2709 .TP .TP
2707 2710 .BI ":[line]mkdir[!] dir ..." .BI ":[line]mkdir[!] dir ..."
File data/vim/doc/app/vifm-app.txt changed (mode: 100644) (index 53818aa10..8c1008e84)
1 *vifm-app.txt* For Vifm version 0.15 Last change: 2025 July 22
1 *vifm-app.txt* For Vifm version 0.15 Last change: 2025 July 23
2 2
3 3 Email for bugs and suggestions: <xaizek@posteo.net> Email for bugs and suggestions: <xaizek@posteo.net>
4 4
 
... ... order using the '.' operator. Any whitespace is ignored.
2311 2311 display media management menu. See |vifm-menus-and-dialogs| for display media management menu. See |vifm-menus-and-dialogs| for
2312 2312 controls. See also |vifm-'mediaprg'| option. controls. See also |vifm-'mediaprg'| option.
2313 2313
2314 :mes[sages] *vifm-:messages* *vifm-:mes*
2315 display previously given status bar messages (up to 50).
2314 *vifm-:messages* *vifm-:mes*
2315 :mes[sages]
2316 display the history of the status bar messages (up to 50 items).
2317 :mes[sages] clear
2318 clear the history of the most recent status bar messages.
2316 2319
2317 2320 :[line]mkdir[!] dir... *vifm-:mkdir* :[line]mkdir[!] dir... *vifm-:mkdir*
2318 2321 create directories at specified paths. The [line] can be used to pick create directories at specified paths. The [line] can be used to pick
File src/cmd_completion.c changed (mode: 100644) (index 9f00e2730..9eda1c771)
... ... non_path_completion(completion_data_t *data)
258 258 if(argc == 0) if(argc == 0)
259 259 complete_winrun(args); complete_winrun(args);
260 260 } }
261 else if(id == COM_MESSAGES)
262 {
263 if(earg_num(argc, args) <= 1)
264 {
265 static const char *parameters[][2] = {
266 { "clear", "clears the history of recent statusbar messages" },
267 };
268 complete_from_string_list(args, parameters, ARRAY_LEN(parameters),
269 /*ignore_case=*/0);
270 }
271 }
261 272 else if(id == COM_AUTOCMD) else if(id == COM_AUTOCMD)
262 273 { {
263 274 /* Complete only first argument. */ /* Complete only first argument. */
File src/cmd_completion.h changed (mode: 100644) (index 8e81d2562..4436d1c81)
... ... enum
57 57 COM_INVERT, COM_INVERT,
58 58 COM_KEEPSEL, COM_KEEPSEL,
59 59 COM_LET, COM_LET,
60 COM_MESSAGES,
60 61 COM_MKDIR, COM_MKDIR,
61 62 COM_MOVE, COM_MOVE,
62 63 COM_PLUGIN, COM_PLUGIN,
File src/cmd_handlers.c changed (mode: 100644) (index e3b91bbe4..5a21128f5)
... ... const cmd_add_t cmds_list[] = {
673 673 .flags = HAS_COMMENT, .flags = HAS_COMMENT,
674 674 .handler = &media_cmd, .min_args = 0, .max_args = 0, }, .handler = &media_cmd, .min_args = 0, .max_args = 0, },
675 675 #endif #endif
676 { .name = "messages", .abbr = "mes", .id = -1,
677 .descr = "display previous status bar messages",
676 { .name = "messages", .abbr = "mes", .id = COM_MESSAGES,
677 .descr = "display or clear previous status bar messages",
678 678 .flags = HAS_COMMENT, .flags = HAS_COMMENT,
679 .handler = &messages_cmd, .min_args = 0, .max_args = 0, },
679 .handler = &messages_cmd, .min_args = 0, .max_args = 1, },
680 680 { .name = "mkdir", .abbr = NULL, .id = COM_MKDIR, { .name = "mkdir", .abbr = NULL, .id = COM_MKDIR,
681 681 .descr = "create directories", .descr = "create directories",
682 682 .flags = HAS_EMARK | HAS_RANGE | HAS_QUOTED_ARGS | HAS_COMMENT .flags = HAS_EMARK | HAS_RANGE | HAS_QUOTED_ARGS | HAS_COMMENT
 
... ... media_cmd(const cmd_info_t *cmd_info)
3851 3851
3852 3852 #endif #endif
3853 3853
3854 /* Displays some of the most recent statusbar messages. */
3854 /* Displays or clears the history of the most recent statusbar messages. */
3855 3855 static int static int
3856 3856 messages_cmd(const cmd_info_t *cmd_info) messages_cmd(const cmd_info_t *cmd_info)
3857 3857 { {
3858 if(cmd_info->argc == 1)
3859 {
3860 if(strcmp(cmd_info->argv[0], "clear") != 0)
3861 {
3862 ui_sb_errf("Invalid argument: %s", cmd_info->argv[0]);
3863 return CMDS_ERR_CUSTOM;
3864 }
3865
3866 stats_clear_msgs(&curr_stats);
3867 return 0;
3868 }
3869
3858 3870 return (ui_sb_msg_show_history() != 0); return (ui_sb_msg_show_history() != 0);
3859 3871 } }
3860 3872
File src/status.c changed (mode: 100644) (index 54278743b..9b556d750)
... ... load_def_values(status_t *stats, config_t *config)
174 174
175 175 stats->direct_color = 0; stats->direct_color = 0;
176 176
177 stats->msg_head = 0;
178 stats->msg_tail = 0;
179 size_t i;
180 for(i = 0U; i < ARRAY_LEN(stats->msgs); ++i)
181 {
182 update_string(&stats->msgs[i], NULL);
183 }
177 stats_clear_msgs(stats);
184 178
185 179 stats->scroll_bind_off = 0; stats->scroll_bind_off = 0;
186 180 stats->split = VSPLIT; stats->split = VSPLIT;
 
... ... stats_save_msg(const char msg[])
373 367 curr_stats.msgs[curr_stats.msg_tail] = strdup(msg); curr_stats.msgs[curr_stats.msg_tail] = strdup(msg);
374 368 } }
375 369
370 void
371 stats_clear_msgs(status_t *stats)
372 {
373 stats->msg_head = 0;
374 stats->msg_tail = 0;
375
376 size_t i;
377 for(i = 0U; i < ARRAY_LEN(stats->msgs); ++i)
378 {
379 update_string(&stats->msgs[i], NULL);
380 }
381 }
382
376 383 void void
377 384 stats_set_quickview(int on) stats_set_quickview(int on)
378 385 { {
File src/status.h changed (mode: 100644) (index a61d586d7..ef98ff7cd)
... ... int stats_file_choose_action_set(void);
270 270 /* Records status bar message. */ /* Records status bar message. */
271 271 void stats_save_msg(const char msg[]); void stats_save_msg(const char msg[]);
272 272
273 /* Clears history of the most recent statusbar messages. */
274 void stats_clear_msgs(status_t *stats);
275
273 276 /* Updates curr_stats.preview.on field and performs necessary updates in other /* Updates curr_stats.preview.on field and performs necessary updates in other
274 277 * parts of the application. */ * parts of the application. */
275 278 void stats_set_quickview(int on); void stats_set_quickview(int on);
File tests/commands/completion.c changed (mode: 100644) (index f6b877a75..101f7c1e6)
... ... dummy_handler(OPT_OP op, optval_t val)
669 669 ASSERT_NO_COMPLETION(L"nosuchcommand a"); ASSERT_NO_COMPLETION(L"nosuchcommand a");
670 670 } }
671 671
672 TEST(messages_is_completed)
673 {
674 ASSERT_COMPLETION(L"messages d", L"messages d");
675
676 ASSERT_COMPLETION(L"messages ", L"messages clear");
677 ASSERT_COMPLETION(L"messages c", L"messages clear");
678
679 ASSERT_COMPLETION(L"messages c c", L"messages c c");
680 }
681
672 682 static void static void
673 683 prepare_for_line_completion(const wchar_t str[]) prepare_for_line_completion(const wchar_t str[])
674 684 { {
File tests/commands/misc.c changed (mode: 100644) (index 7f712a2d6..87c0d0610)
... ... TEST(messages_command)
671 671 assert_failure(cmds_dispatch1("messages", &lwin, CIT_COMMAND)); assert_failure(cmds_dispatch1("messages", &lwin, CIT_COMMAND));
672 672 assert_string_starts_with("2 error\n", ui_sb_last()); assert_string_starts_with("2 error\n", ui_sb_last());
673 673 assert_string_ends_with("\n51 info", ui_sb_last()); assert_string_ends_with("\n51 info", ui_sb_last());
674
675 /* History can be cleared. */
676 ui_sb_msg("");
677 assert_failure(cmds_dispatch1("messages typo", &lwin, CIT_COMMAND));
678 assert_string_equal("Invalid argument: typo", ui_sb_last());
679 ui_sb_msg("");
680 assert_success(cmds_dispatch1("messages clear", &lwin, CIT_COMMAND));
681 assert_string_equal("", ui_sb_last());
682 assert_success(cmds_dispatch1("messages", &lwin, CIT_COMMAND));
683 assert_string_equal("", ui_sb_last());
684 /* And repopulated. */
685 ui_sb_msg("new 1");
686 ui_sb_msg("new 2");
687 assert_failure(cmds_dispatch1("messages", &lwin, CIT_COMMAND));
688 assert_string_equal("new 1\nnew 2", ui_sb_last());
674 689 } }
675 690
676 691 static void static void
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