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 825519599b3a03f9966a04b07cc0f2f1efbea8f9

Add :messages command
Author: xaizek
Author date (UTC): 2011-09-24 21:38
Committer name: xaizek
Committer date (UTC): 2011-09-24 21:38
Parent(s): 362dad2222818ebce54dcd430105fcdef143a2d3
Signing key:
Tree: a36195f0c5c79caf8e431b0f060b0a90711da83e
File Lines added Lines deleted
ChangeLog 2 0
TODO 0 1
src/commands.c 36 0
src/signals.c 1 0
src/status.c 4 0
src/status.h 4 0
src/ui.c 20 1
src/vifm.1 4 1
src/vim/doc/vifm.txt 3 0
src/vim/syntax/vifm.vim 7 6
File ChangeLog changed (mode: 100644) (index dde5801c2..ca12d59ce)
151 151
152 152 Added 'slowfs' option. Added 'slowfs' option.
153 153
154 Added :messages command.
155
154 156 Now spaces between option name and '?' or '!' are allowed in :set command. Now spaces between option name and '?' or '!' are allowed in :set command.
155 157
156 158 Handle multi line output of :set command (for example, Handle multi line output of :set command (for example,
File TODO changed (mode: 100644) (index f0763af9f..094fe23ec)
... ... Vi(m) specific features that need to be added.
28 28 :map without arguments :map without arguments
29 29 Better ranges. Better ranges.
30 30 Ctrl-A and Ctrl-X commands. Ctrl-A and Ctrl-X commands.
31 Add :messages command.
32 31
33 32 Possible things to add. Possible things to add.
34 33 Use system wide mimetypes file. /etc/mailcap? Use system wide mimetypes file. /etc/mailcap?
File src/commands.c changed (mode: 100644) (index 2572ce378..53098a471)
... ... static int ls_cmd(const struct cmd_info *cmd_info);
175 175 static int map_cmd(const struct cmd_info *cmd_info); static int map_cmd(const struct cmd_info *cmd_info);
176 176 static int mark_cmd(const struct cmd_info *cmd_info); static int mark_cmd(const struct cmd_info *cmd_info);
177 177 static int marks_cmd(const struct cmd_info *cmd_info); static int marks_cmd(const struct cmd_info *cmd_info);
178 static int messages_cmd(const struct cmd_info *cmd_info);
178 179 static int mkdir_cmd(const struct cmd_info *cmd_info); static int mkdir_cmd(const struct cmd_info *cmd_info);
179 180 static int move_cmd(const struct cmd_info *cmd_info); static int move_cmd(const struct cmd_info *cmd_info);
180 181 static int nmap_cmd(const struct cmd_info *cmd_info); static int nmap_cmd(const struct cmd_info *cmd_info);
 
... ... static const struct cmd_add commands[] = {
302 303 .handler = mark_cmd, .qmark = 0, .expand = 1, .cust_sep = 0, .min_args = 1, .max_args = 3, .select = 0, }, .handler = mark_cmd, .qmark = 0, .expand = 1, .cust_sep = 0, .min_args = 1, .max_args = 3, .select = 0, },
303 304 { .name = "marks", .abbr = NULL, .emark = 0, .id = -1, .range = 0, .bg = 0, .quote = 0, .regexp = 0, { .name = "marks", .abbr = NULL, .emark = 0, .id = -1, .range = 0, .bg = 0, .quote = 0, .regexp = 0,
304 305 .handler = marks_cmd, .qmark = 0, .expand = 0, .cust_sep = 0, .min_args = 0, .max_args = NOT_DEF, .select = 0, }, .handler = marks_cmd, .qmark = 0, .expand = 0, .cust_sep = 0, .min_args = 0, .max_args = NOT_DEF, .select = 0, },
306 { .name = "messages", .abbr = "mes", .emark = 0, .id = -1, .range = 0, .bg = 0, .quote = 0, .regexp = 0,
307 .handler = messages_cmd, .qmark = 0, .expand = 0, .cust_sep = 0, .min_args = 0, .max_args = 0, .select = 0, },
305 308 { .name = "mkdir", .abbr = NULL, .emark = 1, .id = -1, .range = 0, .bg = 0, .quote = 1, .regexp = 0, { .name = "mkdir", .abbr = NULL, .emark = 1, .id = -1, .range = 0, .bg = 0, .quote = 1, .regexp = 0,
306 309 .handler = mkdir_cmd, .qmark = 0, .expand = 0, .cust_sep = 0, .min_args = 1, .max_args = NOT_DEF, .select = 0, }, .handler = mkdir_cmd, .qmark = 0, .expand = 0, .cust_sep = 0, .min_args = 1, .max_args = NOT_DEF, .select = 0, },
307 310 { .name = "move", .abbr = "m", .emark = 1, .id = -1, .range = 1, .bg = 0, .quote = 1, .regexp = 0, { .name = "move", .abbr = "m", .emark = 1, .id = -1, .range = 1, .bg = 0, .quote = 1, .regexp = 0,
 
... ... marks_cmd(const struct cmd_info *cmd_info)
3504 3507 return show_bookmarks_menu(curr_view, buf); return show_bookmarks_menu(curr_view, buf);
3505 3508 } }
3506 3509
3510 static int
3511 messages_cmd(const struct cmd_info *cmd_info)
3512 {
3513 char *lines;
3514 size_t len;
3515 int count;
3516 int t;
3517
3518 lines = NULL;
3519 len = 0;
3520 count = curr_stats.msg_tail - curr_stats.msg_head;
3521 if(count < 0)
3522 count += ARRAY_LEN(curr_stats.msgs);
3523 t = (curr_stats.msg_head + 1) % ARRAY_LEN(curr_stats.msgs);
3524 while(count-- > 0)
3525 {
3526 const char *msg = curr_stats.msgs[t];
3527 lines = realloc(lines, len + 1 + strlen(msg) + 1);
3528 len += sprintf(lines + len, "%s%s", (len == 0) ? "": "\n", msg);
3529 t = (t + 1) % ARRAY_LEN(curr_stats.msgs);
3530 }
3531
3532 if(lines == NULL)
3533 return 0;
3534
3535 curr_stats.save_msg_in_list = 0;
3536 status_bar_message(lines);
3537 curr_stats.save_msg_in_list = 1;
3538
3539 free(lines);
3540 return 1;
3541 }
3542
3507 3543 static int static int
3508 3544 mkdir_cmd(const struct cmd_info *cmd_info) mkdir_cmd(const struct cmd_info *cmd_info)
3509 3545 { {
File src/signals.c changed (mode: 100644) (index 23f91f47b..1913291d8)
42 42 #include "modes.h" #include "modes.h"
43 43 #include "status.h" #include "status.h"
44 44 #include "ui.h" #include "ui.h"
45 #include "utils.h"
45 46
46 47 #include "signals.h" #include "signals.h"
47 48
File src/status.c changed (mode: 100644) (index bca946a1b..36650ad74)
... ... init_status(void)
56 56 #ifdef HAVE_LIBGTK #ifdef HAVE_LIBGTK
57 57 curr_stats.gtk_available = 0; curr_stats.gtk_available = 0;
58 58 #endif #endif
59
60 curr_stats.msg_head = 0;
61 curr_stats.msg_tail = 0;
62 curr_stats.save_msg_in_list = 1;
59 63 } }
60 64
61 65 /* vim: set tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab cinoptions-=(0 : */ /* vim: set tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab cinoptions-=(0 : */
File src/status.h changed (mode: 100644) (index d76a7d7f5..6faf63513)
... ... typedef struct
74 74 #ifdef HAVE_LIBGTK #ifdef HAVE_LIBGTK
75 75 int gtk_available; /* for mimetype detection */ int gtk_available; /* for mimetype detection */
76 76 #endif #endif
77
78 int msg_head, msg_tail;
79 char *msgs[51];
80 int save_msg_in_list;
77 81 }Status; }Status;
78 82
79 83 extern Status curr_stats; extern Status curr_stats;
File src/ui.c changed (mode: 100644) (index 2dad07a5e..8bbc1d2a7)
... ... update_stat_window(FileView *view)
181 181 wrefresh(stat_win); wrefresh(stat_win);
182 182 } }
183 183
184 static void
185 save_status_bar_msg(const char *msg)
186 {
187 if(!curr_stats.save_msg_in_list)
188 return;
189
190 if(curr_stats.msg_tail != curr_stats.msg_head &&
191 strcmp(curr_stats.msgs[curr_stats.msg_tail], msg) == 0)
192 return;
193
194 curr_stats.msg_tail = (curr_stats.msg_tail + 1) % ARRAY_LEN(curr_stats.msgs);
195 if(curr_stats.msg_tail == curr_stats.msg_head)
196 free(curr_stats.msgs[curr_stats.msg_head]);
197 curr_stats.msgs[curr_stats.msg_tail] = strdup(msg);
198 }
199
184 200 static void static void
185 201 status_bar_message_i(const char *message, int error) status_bar_message_i(const char *message, int error)
186 202 { {
 
... ... status_bar_message_i(const char *message, int error)
204 220 free(msg); free(msg);
205 221 msg = p; msg = p;
206 222 err = error; err = error;
223
224 save_status_bar_msg(msg);
207 225 } }
208 226
209 assert(msg != NULL);
227 if(msg == NULL)
228 return;
210 229
211 230 p = msg; p = msg;
212 231 q = msg - 1; q = msg - 1;
File src/vifm.1 changed (mode: 100644) (index 005058595..de053dcbe)
1 .TH vifm 1 "September 24, 2011" "" "Vifm"
1 .TH vifm 1 "September 25, 2011" "" "Vifm"
2 2 .\" --------------------------------------------------------------------------- .\" ---------------------------------------------------------------------------
3 3 .SH NAME .SH NAME
4 4 .\" --------------------------------------------------------------------------- .\" ---------------------------------------------------------------------------
 
... ... create a popup menu of bookmarks.
961 961 .BI ":marks list ..." .BI ":marks list ..."
962 962 display the contents of the marks that are mentioned in list. display the contents of the marks that are mentioned in list.
963 963 .TP .TP
964 .BI ":mes[sages]
965 shows previously given messages (up to 50).
966 .TP
964 967 .BI ":mkdir[!] dir ..." .BI ":mkdir[!] dir ..."
965 968 creates directories with given names. "!" means make parent directories as creates directories with given names. "!" means make parent directories as
966 969 needed. needed.
File src/vim/doc/vifm.txt changed (mode: 100644) (index 59233653b..ed075b053)
... ... of the hierarchy and transparency for all others.
706 706 :marks - menu of bookmarks. :marks - menu of bookmarks.
707 707 :marks list ... - display the contents of the marks that are mentioned in list. :marks list ... - display the contents of the marks that are mentioned in list.
708 708
709 *vifm-:messages* *vifm-:mes*
710 :mes[sages] - shows previously given messages (up to 50).
711
709 712 *vifm-:mkdir* *vifm-:mkdir*
710 713 :mkdir[!] dir... - creates directories with given names. "!" means make :mkdir[!] dir... - creates directories with given names. "!" means make
711 714 parent directories as needed. parent directories as needed.
File src/vim/syntax/vifm.vim changed (mode: 100644) (index a1a239620..a82a52df0)
1 1 " vifm syntax file " vifm syntax file
2 2 " Maintainer: xaizek <xaizek@gmail.com> " Maintainer: xaizek <xaizek@gmail.com>
3 " Last Change: September 13, 2011
3 " Last Change: September 25, 2011
4 4 " Based On: Vim syntax file by Dr. Charles E. Campbell, Jr. " Based On: Vim syntax file by Dr. Charles E. Campbell, Jr.
5 5
6 6 if exists('b:current_syntax') if exists('b:current_syntax')
 
... ... set cpo-=C
14 14
15 15 " General commands " General commands
16 16 syntax keyword vifmCommand contained alink apropos cd change chmod chown clone syntax keyword vifmCommand contained alink apropos cd change chmod chown clone
17 \ co[py] d[elete] delm[arks] di[splay] dirs e[dit] empty exi[t] file filter
18 \ fin[d] gr[ep] h[elp] hi[ghlight] his[tory] invert jobs locate ls marks
19 \ mkdir m[ove] noh[lsearch] on[ly] popd pushd pwd q[uit] reg[isters] rename
20 \ restart restore rlink screen se[t] sh[ell] sor[t] sp[lit] s[ubstitute]
21 \ touch tr sync undol[ist] ve[rsion] vie[w] vifm w[rite] wq x[it] y[ank]
17 \ co[py] d[elete] delm[arks] di[splay] dirs e[dit] empty exi[t] file
18 \ filter fin[d] gr[ep] h[elp] hi[ghlight] his[tory] invert jobs locate ls
19 \ marks mes[sages] mkdir m[ove] noh[lsearch] on[ly] popd pushd pwd q[uit]
20 \ reg[isters] rename restart restore rlink screen se[t] sh[ell] sor[t]
21 \ sp[lit] s[ubstitute] touch tr sync undol[ist] ve[rsion] vie[w] vifm
22 \ w[rite] wq x[it] y[ank]
22 23
23 24 " Map commands " Map commands
24 25 syntax keyword vifmMap contained cm[ap] cno[remap] cu[nmap] map nm[ap] syntax keyword vifmMap contained cm[ap] cno[remap] cu[nmap] map nm[ap]
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