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 8bb0c9c33d505f9db0084f826e6d0248d2b53afc

Implemented :yank command. Fixed '< and '>.
Author: xaizek
Author date (UTC): 2011-06-18 21:00
Committer name: xaizek
Committer date (UTC): 2011-06-18 21:00
Parent(s): bbbd83dd9f23251a4f535d660be525138e4e572c
Signing key:
Tree: 1474ea1a0a5b905b16cc720c4e999cfc85ae7d4e
File Lines added Lines deleted
ChangeLog 4 0
src/bookmarks.c 23 8
src/bookmarks.h 1 0
src/commands.c 4 26
src/filelist.c 5 17
src/modes.c 3 0
src/visual.c 23 0
File ChangeLog changed (mode: 100644) (index 0617ef83b..098fe1e29)
29 29
30 30 Added Ctrl-C key handling to error message dialog. Added Ctrl-C key handling to error message dialog.
31 31
32 Implemented :yank command.
33
34 Fixed '< and '> marks handling.
35
32 36 0.6 to 0.6.1 0.6 to 0.6.1
33 37
34 38 Added :set command. Added :set command.
File src/bookmarks.c changed (mode: 100644) (index 424a32a2a..a7cd0178f)
... ... remove_bookmark(const int x)
108 108 status_bar_message("Could not find mark"); status_bar_message("Could not find mark");
109 109 } }
110 110
111 void
112 add_bookmark(const char mark, const char *directory, const char *file)
111 static void
112 add_mark(const char mark, const char *directory, const char *file)
113 113 { {
114 114 int x ; int x ;
115 115
116 if(!isalnum(mark))
117 {
118 status_bar_message("Invalid mark");
119 return;
120 }
121
122 116 x = mark2index(mark); x = mark2index(mark);
123 117
124 118 /* The mark is already being used. Free pointers first! */ /* The mark is already being used. Free pointers first! */
 
... ... add_bookmark(const char mark, const char *directory, const char *file)
132 126 curr_stats.setting_change = 1; curr_stats.setting_change = 1;
133 127 } }
134 128
129 void
130 add_bookmark(const char mark, const char *directory, const char *file)
131 {
132 if(!isalnum(mark))
133 {
134 status_bar_message("Invalid mark");
135 return;
136 }
137
138 add_mark(mark, directory, file);
139 }
140
141 void
142 set_specmark(const char mark, const char *directory, const char *file)
143 {
144 if(mark != '<' && mark != '>')
145 return;
146
147 add_mark(mark, directory, file);
148 }
149
135 150 int int
136 151 move_to_bookmark(FileView *view, char mark) move_to_bookmark(FileView *view, char mark)
137 152 { {
File src/bookmarks.h changed (mode: 100644) (index 867c44b1b..9143a6df7)
... ... void init_bookmarks(void);
55 55 char index2mark(const int x); char index2mark(const int x);
56 56 int is_bookmark(const int x); int is_bookmark(const int x);
57 57 void add_bookmark(const char mark, const char *directory, const char *file); void add_bookmark(const char mark, const char *directory, const char *file);
58 void set_specmark(const char mark, const char *directory, const char *file);
58 59 int get_bookmark(FileView *view, char key); int get_bookmark(FileView *view, char key);
59 60 int move_to_bookmark(FileView *view, const char mark); int move_to_bookmark(FileView *view, const char mark);
60 61 void remove_bookmark(const int x); void remove_bookmark(const int x);
File src/commands.c changed (mode: 100644) (index c605e71f5..54908ceae)
... ... execute_builtin_command(FileView *view, cmd_t *cmd)
1296 1296 show_cmdhistory_menu(view); show_cmdhistory_menu(view);
1297 1297 break; break;
1298 1298 case COM_DELETE: case COM_DELETE:
1299 {
1300 /*
1301 int selection_worked;
1302
1303 selection_worked = select_files_in_range(view, cmd);
1304
1305 if (selection_worked)
1306 */
1307 select_files_in_range(view, cmd);
1308 delete_file(view, DEFAULT_REG_NAME, 0, NULL, 1);
1309 }
1299 select_files_in_range(view, cmd);
1300 delete_file(view, DEFAULT_REG_NAME, 0, NULL, 1);
1310 1301 break; break;
1311 1302 case COM_DELCOMMAND: case COM_DELCOMMAND:
1312 1303 { {
 
... ... execute_builtin_command(FileView *view, cmd_t *cmd)
1570 1561 break; break;
1571 1562 case COM_VIFM: case COM_VIFM:
1572 1563 show_vifm_menu(view); show_vifm_menu(view);
1573 // show_error_msg("I haven't gotten here yet",
1574 // "Sorry this is not implemented");
1575 1564 break; break;
1576 1565 case COM_YANK: case COM_YANK:
1577 {
1578 /*
1579 TODO do we need this?
1580 int selection_worked = 0;
1581
1582 selection_worked = select_files_in_range(view);
1583
1584 if (selection_worked)
1585 yank_selected_files(view);
1586 */
1587 show_error_msg(":yank is not implemented yet",
1588 ":yank is not implemented yet");
1589 }
1566 select_files_in_range(view, cmd);
1567 yank_files(view, DEFAULT_REG_NAME, 0, NULL);
1590 1568 break; break;
1591 1569 case COM_VMAP: case COM_VMAP:
1592 1570 save_msg = do_map(cmd, "Visual", "vmap", VISUAL_MODE); save_msg = do_map(cmd, "Visual", "vmap", VISUAL_MODE);
File src/filelist.c changed (mode: 100644) (index ccbd8a035..5a3008d6f)
... ... change_directory(FileView *view, const char *directory)
1247 1247 if(strcmp(dir_dup, view->curr_dir)) if(strcmp(dir_dup, view->curr_dir))
1248 1248 snprintf(view->curr_dir, PATH_MAX, "%s", dir_dup); snprintf(view->curr_dir, PATH_MAX, "%s", dir_dup);
1249 1249
1250 closedir(dir);
1251
1250 1252 /* Save the directory modified time to check for file changes */ /* Save the directory modified time to check for file changes */
1251 1253 stat(view->curr_dir, &s); stat(view->curr_dir, &s);
1252 1254 view->dir_mtime = s.st_mtime; view->dir_mtime = s.st_mtime;
1253 closedir(dir);
1254 1255
1255 1256 save_view_history(view); save_view_history(view);
1256 1257 return 0; return 0;
 
... ... load_dir_list(FileView *view, int reload)
1290 1291
1291 1292 view->filtered = 0; view->filtered = 0;
1292 1293
1293 lstat(view->curr_dir, &s);
1294 stat(view->curr_dir, &s);
1294 1295 view->dir_mtime = s.st_mtime; view->dir_mtime = s.st_mtime;
1295 1296
1296 1297 if(!reload && s.st_size > 2048) if(!reload && s.st_size > 2048)
 
... ... scroll_view(FileView *view)
1642 1643 static void static void
1643 1644 reload_window(FileView *view) reload_window(FileView *view)
1644 1645 { {
1645 struct stat s;
1646
1647 1646 curr_stats.skip_history = 1; curr_stats.skip_history = 1;
1648 1647
1649 stat(view->curr_dir, &s);
1650 if(view != curr_view)
1651 change_directory(view, view->curr_dir);
1652
1648 change_directory(view, view->curr_dir);
1653 1649 load_dir_list(view, 1); load_dir_list(view, 1);
1654 view->dir_mtime = s.st_mtime;
1655 1650
1656 1651 if(view != curr_view) if(view != curr_view)
1657 1652 { {
 
... ... check_if_filelists_have_changed(FileView *view)
1680 1675 leave_invalid_dir(view, view->curr_dir); leave_invalid_dir(view, view->curr_dir);
1681 1676 change_directory(view, view->curr_dir); change_directory(view, view->curr_dir);
1682 1677 clean_selected_files(view); clean_selected_files(view);
1683 s.st_mtime = -1; /* force window reload */
1678 s.st_mtime = 0; /* force window reload */
1684 1679 } }
1685 1680 if(s.st_mtime != view->dir_mtime) if(s.st_mtime != view->dir_mtime)
1686 1681 reload_window(view); reload_window(view);
1687
1688 if(curr_stats.number_of_windows != 1 && curr_stats.view != 1)
1689 {
1690 stat(other_view->curr_dir, &s);
1691 if(s.st_mtime != other_view->dir_mtime)
1692 reload_window(other_view);
1693 }
1694 1682 } }
1695 1683
1696 1684 void void
File src/modes.c changed (mode: 100644) (index 5d5118dc2..32c29e9e8)
... ... modes_pre(void)
85 85 } }
86 86
87 87 check_if_filelists_have_changed(curr_view); check_if_filelists_have_changed(curr_view);
88 if(curr_stats.number_of_windows != 1 && curr_stats.view != 1)
89 check_if_filelists_have_changed(other_view);
90
88 91 check_background_jobs(); check_background_jobs();
89 92
90 93 if(!curr_stats.save_msg) if(!curr_stats.save_msg)
File src/visual.c changed (mode: 100644) (index 8cc6484f7..07395028b)
23 23
24 24 #include "../config.h" #include "../config.h"
25 25
26 #include "bookmarks.h"
26 27 #include "cmdline.h" #include "cmdline.h"
27 28 #include "commands.h" #include "commands.h"
28 29 #include "filelist.h" #include "filelist.h"
 
... ... static void cmd_k(struct key_info, struct keys_info *);
57 58 static void cmd_y(struct key_info, struct keys_info *); static void cmd_y(struct key_info, struct keys_info *);
58 59 static void select_up_one(FileView *view, int start_pos); static void select_up_one(FileView *view, int start_pos);
59 60 static void select_down_one(FileView *view, int start_pos); static void select_down_one(FileView *view, int start_pos);
61 static void update_marks(FileView *view);
60 62 static void update(void); static void update(void);
61 63
62 64 void void
 
... ... enter_visual_mode(void)
152 154 else else
153 155 status_bar_message("-- VISUAL --"); status_bar_message("-- VISUAL --");
154 156 curr_stats.save_msg = 1; curr_stats.save_msg = 1;
157
158 update_marks(view);
155 159 } }
156 160
157 161 void void
 
... ... select_up_one(FileView *view, int start_pos)
418 422 view->dir_entry[view->list_pos +1].selected = 0; view->dir_entry[view->list_pos +1].selected = 0;
419 423 view->selected_files--; view->selected_files--;
420 424 } }
425
426 update_marks(view);
421 427 } }
422 428
423 429 /* move down one position in the window, adding to the selection list */ /* move down one position in the window, adding to the selection list */
 
... ... select_down_one(FileView *view, int start_pos)
453 459 view->dir_entry[view->list_pos -1].selected = 0; view->dir_entry[view->list_pos -1].selected = 0;
454 460 view->selected_files--; view->selected_files--;
455 461 } }
462
463 update_marks(view);
464 }
465
466 static void
467 update_marks(FileView *view)
468 {
469 if(view->list_pos < start_pos)
470 {
471 set_specmark('<', view->curr_dir, get_current_file_name(view));
472 set_specmark('>', view->curr_dir, view->dir_entry[start_pos].name);
473 }
474 else
475 {
476 set_specmark('<', view->curr_dir, view->dir_entry[start_pos].name);
477 set_specmark('>', view->curr_dir, get_current_file_name(view));
478 }
456 479 } }
457 480
458 481 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