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 b81ebbf7119809094c97ffe623b2747eefcd0c1b

Add gv normal mode command.
Switched to visual mode and restores last selection if possible.
Author: xaizek
Author date (UTC): 2011-06-18 21:53
Committer name: xaizek
Committer date (UTC): 2011-06-18 21:53
Parent(s): 4dceb97a69986c67c1bf27ac9757224b56a204ea
Signing key:
Tree: 8e7e2acb74396d621a0b24bdfe90cb3ed10aceac
File Lines added Lines deleted
ChangeLog 2 0
src/normal.c 11 1
src/vifm-help.txt 1 0
src/vifm.1 3 0
src/vifm.txt 1 0
src/visual.c 22 10
src/visual.h 1 1
File ChangeLog changed (mode: 100644) (index 027e2498f..82861333f)
35 35
36 36 Added o and O keys for Visual mode (switch selection bound). Added o and O keys for Visual mode (switch selection bound).
37 37
38 Added gv normal mode command.
39
38 40 0.6 to 0.6.1 0.6 to 0.6.1
39 41
40 42 Added :set command. Added :set command.
File src/normal.c changed (mode: 100644) (index d80246133..3423c21ec)
... ... static void find_f(int ch);
112 112 static void cmd_ga(struct key_info, struct keys_info *); static void cmd_ga(struct key_info, struct keys_info *);
113 113 static void cmd_gg(struct key_info, struct keys_info *); static void cmd_gg(struct key_info, struct keys_info *);
114 114 static void selector_gg(struct key_info, struct keys_info *); static void selector_gg(struct key_info, struct keys_info *);
115 static void cmd_gv(struct key_info, struct keys_info *);
115 116 static void cmd_h(struct key_info, struct keys_info *); static void cmd_h(struct key_info, struct keys_info *);
116 117 static void cmd_i(struct key_info, struct keys_info *); static void cmd_i(struct key_info, struct keys_info *);
117 118 static void cmd_j(struct key_info, struct keys_info *); static void cmd_j(struct key_info, struct keys_info *);
 
... ... init_normal_mode(int *key_mode)
332 333 curr = add_cmd(L"gg", NORMAL_MODE); curr = add_cmd(L"gg", NORMAL_MODE);
333 334 curr->data.handler = cmd_gg; curr->data.handler = cmd_gg;
334 335
336 curr = add_cmd(L"gv", NORMAL_MODE);
337 curr->data.handler = cmd_gv;
338
335 339 curr = add_cmd(L"h", NORMAL_MODE); curr = add_cmd(L"h", NORMAL_MODE);
336 340 curr->data.handler = cmd_h; curr->data.handler = cmd_h;
337 341
 
... ... selector_gg(struct key_info key_info, struct keys_info *keys_info)
755 759 pick_files(curr_view, key_info.count - 1, keys_info); pick_files(curr_view, key_info.count - 1, keys_info);
756 760 } }
757 761
762 static void
763 cmd_gv(struct key_info key_info, struct keys_info *keys_info)
764 {
765 enter_visual_mode(1);
766 }
767
758 768 /* Go to first file in window. */ /* Go to first file in window. */
759 769 static void static void
760 770 cmd_H(struct key_info key_info, struct keys_info *keys_info) cmd_H(struct key_info key_info, struct keys_info *keys_info)
 
... ... cmd_P(struct key_info key_info, struct keys_info *keys_info)
837 847 static void static void
838 848 cmd_V(struct key_info key_info, struct keys_info *keys_info) cmd_V(struct key_info key_info, struct keys_info *keys_info)
839 849 { {
840 enter_visual_mode();
850 enter_visual_mode(0);
841 851 } }
842 852
843 853 static void static void
File src/vifm-help.txt changed (mode: 100644) (index 4c75d81d3..a978c8e87)
... ... The basic vi key bindings are used to move through the files and popup
12 12
13 13 gg top of list gg top of list
14 14 ga calculate size of directory ga calculate size of directory
15 gv go to visual mode restoring last selection.
15 16 G bottom of list G bottom of list
16 17 H move to the first file in the window. H move to the first file in the window.
17 18 M move to the file in the middle of the window. M move to the file in the middle of the window.
File src/vifm.1 changed (mode: 100644) (index d816627bd..ca3af9058)
... ... creates a window showing detailed information about the current file.
83 83 .TP .TP
84 84 .BI ga .BI ga
85 85 calculate directory size. calculate directory size.
86 .TP
87 .BI gv
88 gv go to visual mode restoring last selection.
86 89 .SH Scrolling panes .SH Scrolling panes
87 90 .TP .TP
88 91 .BI zt .BI zt
File src/vifm.txt changed (mode: 100644) (index 527b05fbc..d5f719da1)
... ... DD and D<selector> - like dd and d<selector>, but omitting trash directory
197 197 (even when option USE_TRASH is set). (even when option USE_TRASH is set).
198 198 f, F, ;, <comma> - search by first character in filename. f, F, ;, <comma> - search by first character in filename.
199 199 ga calculate size of directory. ga calculate size of directory.
200 gv go to visual mode restoring last selection.
200 201 yy, Y - yank selected files. yy, Y - yank selected files.
201 202 y<selector> - yank files. y<selector> - yank files.
202 203 p - put last selected files. p - put last selected files.
File src/visual.c changed (mode: 100644) (index 6aa1da31e..d4194787c)
... ... init_visual_mode(int *key_mode)
135 135 } }
136 136
137 137 void void
138 enter_visual_mode(void)
138 enter_visual_mode(int restore_selection)
139 139 { {
140 140 int x; int x;
141 141
 
... ... enter_visual_mode(void)
146 146 for(x = 0; x < view->list_rows; x++) for(x = 0; x < view->list_rows; x++)
147 147 view->dir_entry[x].selected = 0; view->dir_entry[x].selected = 0;
148 148
149 /* Don't allow the ../ dir to be selected */
150 if(strcmp(view->dir_entry[view->list_pos].name, "../"))
149 if(restore_selection)
151 150 { {
151 int ub = check_mark_directory(view, '<');
152 int lb = check_mark_directory(view, '>');
153
154 if(ub > 0 && lb > 0)
155 {
156 start_pos = ub;
157 view->list_pos = ub;
158
159 view->selected_files = 1;
160 view->dir_entry[view->list_pos].selected = 1;
161
162 while(view->list_pos != lb)
163 select_down_one(view, start_pos);
164 update();
165 }
166 }
167 else if(strcmp(view->dir_entry[view->list_pos].name, "../"))
168 {
169 /* Don't allow the ../ dir to be selected */
152 170 view->selected_files = 1; view->selected_files = 1;
153 171 view->dir_entry[view->list_pos].selected = 1; view->dir_entry[view->list_pos].selected = 1;
154 172 } }
 
... ... enter_visual_mode(void)
156 174 draw_dir_list(view, view->top_line, view->list_pos); draw_dir_list(view, view->top_line, view->list_pos);
157 175 moveto_list_pos(view, view->list_pos); moveto_list_pos(view, view->list_pos);
158 176
159 if(view->list_pos != 0)
160 status_bar_message("-- VISUAL --\t1 File Selected");
161 else
162 status_bar_message("-- VISUAL --");
163 curr_stats.save_msg = 1;
164
165 177 update_marks(view); update_marks(view);
166 178 } }
167 179
 
... ... select_up_one(FileView *view, int start_pos)
410 422 view->list_pos--; view->list_pos--;
411 423 if(view->list_pos < 0) if(view->list_pos < 0)
412 424 { {
413 if (start_pos == 0)
425 if(start_pos == 0)
414 426 view->selected_files = 0; view->selected_files = 0;
415 427 view->list_pos = 0; view->list_pos = 0;
416 428 } }
File src/visual.h changed (mode: 100644) (index 14a4ccc87..9c42e90e0)
20 20 #define __VISUAL_H__ #define __VISUAL_H__
21 21
22 22 void init_visual_mode(int *key_mode); void init_visual_mode(int *key_mode);
23 void enter_visual_mode(void);
23 void enter_visual_mode(int restore_selection);
24 24 void leave_visual_mode(int save_msg); void leave_visual_mode(int save_msg);
25 25
26 26 #endif #endif
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