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 a138aec4b89779943d4100ba9fe22be9e982959b

Fix multi line command line.
Author: xaizek
Author date (UTC): 2011-07-20 17:21
Committer name: xaizek
Committer date (UTC): 2011-07-20 17:21
Parent(s): 1c83ecb76080f53b27d7cb062aef4caf8f2d9204
Signing key:
Tree: 66c5a213981944d983db970038b9445d3d90e35c
File Lines added Lines deleted
src/cmdline.c 34 19
src/main_loop.c 1 0
src/modes.c 6 0
src/ui.c 1 1
File src/cmdline.c changed (mode: 100644) (index 25a1165bb..34f2952ec)
... ... def_handler(wchar_t key)
287 287 if(key != L'\r' && !iswprint(key)) if(key != L'\r' && !iswprint(key))
288 288 return 0; return 0;
289 289
290 p = realloc(input_stat.line, (input_stat.len+2) * sizeof(wchar_t));
290 p = realloc(input_stat.line, (input_stat.len + 2) * sizeof(wchar_t));
291 291 if(p == NULL) if(p == NULL)
292 292 { {
293 293 leave_cmdline_mode(); leave_cmdline_mode();
 
... ... def_handler(wchar_t key)
303 303 wcsins(input_stat.line, buf, input_stat.index); wcsins(input_stat.line, buf, input_stat.index);
304 304 input_stat.len++; input_stat.len++;
305 305
306 if((input_stat.len + 1) % getmaxx(status_bar) == 0)
307 update_cmdline_size();
308
309 306 input_stat.curs_pos += wcwidth(key); input_stat.curs_pos += wcwidth(key);
307
308 update_cmdline_size();
310 309 update_cmdline_text(); update_cmdline_text();
311 310
312 311 return 0; return 0;
 
... ... static void
316 315 update_cmdline_size(void) update_cmdline_size(void)
317 316 { {
318 317 int d; int d;
319 d = (input_stat.prompt_wid + input_stat.len + 1 + line_width - 1)/line_width;
318 int cursor_at_the_end;
319
320 cursor_at_the_end = ((input_stat.prompt_wid + input_stat.len) ==
321 input_stat.curs_pos);
322 d = (input_stat.prompt_wid + input_stat.len + cursor_at_the_end + line_width -
323 1)/line_width;
320 324 mvwin(status_bar, getmaxy(stdscr) - d, 0); mvwin(status_bar, getmaxy(stdscr) - d, 0);
321 325 wresize(status_bar, d, line_width); wresize(status_bar, d, line_width);
322 326
 
... ... update_cmdline_text(void)
330 334 werase(status_bar); werase(status_bar);
331 335 mvwaddwstr(status_bar, 0, 0, input_stat.prompt); mvwaddwstr(status_bar, 0, 0, input_stat.prompt);
332 336 if(input_stat.line != NULL) if(input_stat.line != NULL)
333 mvwaddwstr(status_bar, 0, input_stat.prompt_wid, input_stat.line);
334 wmove(status_bar, 0, input_stat.curs_pos);
337 mvwaddwstr(status_bar, input_stat.prompt_wid/line_width,
338 input_stat.prompt_wid%line_width, input_stat.line);
339 wmove(status_bar, input_stat.curs_pos/line_width,
340 input_stat.curs_pos%line_width);
341 wrefresh(status_bar);
335 342 } }
336 343
337 344 /* Insert a string into another string /* Insert a string into another string
 
... ... prepare_cmdline_mode(const wchar_t *prompt, const wchar_t *cmd)
437 444 input_stat.history_search = 0; input_stat.history_search = 0;
438 445 input_stat.line_buf = NULL; input_stat.line_buf = NULL;
439 446
440 wcsncpy(input_stat.prompt, prompt, sizeof(input_stat.prompt)/sizeof(wchar_t));
447 wcsncpy(input_stat.prompt, prompt, ARRAY_LEN(input_stat.prompt));
441 448 input_stat.prompt_wid = input_stat.curs_pos = wcslen(input_stat.prompt); input_stat.prompt_wid = input_stat.curs_pos = wcslen(input_stat.prompt);
442 449
443 450 if(input_stat.len != 0) if(input_stat.len != 0)
 
... ... cmd_ctrl_h(struct key_info key_info, struct keys_info *keys_info)
542 549 input_stat.len--; input_stat.len--;
543 550
544 551 input_stat.curs_pos -= wcwidth(input_stat.line[input_stat.index]); input_stat.curs_pos -= wcwidth(input_stat.line[input_stat.index]);
545 wcsdel(input_stat.line, input_stat.index+1, 1);
552 wcsdel(input_stat.line, input_stat.index + 1, 1);
546 553
547 554 werase(status_bar); werase(status_bar);
548 555 mvwaddwstr(status_bar, 0, 0, input_stat.prompt); mvwaddwstr(status_bar, 0, 0, input_stat.prompt);
 
... ... cmd_ctrl_u(struct key_info key_info, struct keys_info *keys_info)
746 753 mvwaddwstr(status_bar, 0, 0, input_stat.prompt); mvwaddwstr(status_bar, 0, 0, input_stat.prompt);
747 754 mvwaddwstr(status_bar, 0, input_stat.prompt_wid, input_stat.line); mvwaddwstr(status_bar, 0, input_stat.prompt_wid, input_stat.line);
748 755
749 wmove(status_bar, 0, input_stat.curs_pos);
756 wmove(status_bar, input_stat.curs_pos/line_width,
757 input_stat.curs_pos%line_width);
750 758 } }
751 759
752 760 static void static void
 
... ... cmd_ctrl_w(struct key_info key_info, struct keys_info *keys_info)
769 777 werase(status_bar); werase(status_bar);
770 778 mvwaddwstr(status_bar, 0, 0, input_stat.prompt); mvwaddwstr(status_bar, 0, 0, input_stat.prompt);
771 779 waddwstr(status_bar, input_stat.line); waddwstr(status_bar, input_stat.line);
772 wmove(status_bar, 0, input_stat.curs_pos);
780 wmove(status_bar, input_stat.curs_pos/line_width,
781 input_stat.curs_pos%line_width);
773 782 } }
774 783
775 784 static void static void
776 785 cmd_meta_b(struct key_info key_info, struct keys_info *keys_info) cmd_meta_b(struct key_info key_info, struct keys_info *keys_info)
777 786 { {
778 787 find_prev_word(); find_prev_word();
779 wmove(status_bar, 0, input_stat.curs_pos);
788 wmove(status_bar, input_stat.curs_pos/line_width,
789 input_stat.curs_pos%line_width);
780 790 } }
781 791
782 792 static void static void
 
... ... cmd_meta_d(struct key_info key_info, struct keys_info *keys_info)
816 826 werase(status_bar); werase(status_bar);
817 827 mvwaddwstr(status_bar, 0, 0, input_stat.prompt); mvwaddwstr(status_bar, 0, 0, input_stat.prompt);
818 828 waddwstr(status_bar, input_stat.line); waddwstr(status_bar, input_stat.line);
819 wmove(status_bar, 0, input_stat.curs_pos);
829 wmove(status_bar, input_stat.curs_pos/line_width,
830 input_stat.curs_pos%line_width);
820 831 } }
821 832
822 833 static void static void
823 834 cmd_meta_f(struct key_info key_info, struct keys_info *keys_info) cmd_meta_f(struct key_info key_info, struct keys_info *keys_info)
824 835 { {
825 836 find_next_word(); find_next_word();
826 wmove(status_bar, 0, input_stat.curs_pos);
837 wmove(status_bar, input_stat.curs_pos/line_width,
838 input_stat.curs_pos%line_width);
827 839 } }
828 840
829 841 static void static void
 
... ... cmd_home(struct key_info key_info, struct keys_info *keys_info)
878 890 { {
879 891 input_stat.index = 0; input_stat.index = 0;
880 892 input_stat.curs_pos = wcslen(input_stat.prompt); input_stat.curs_pos = wcslen(input_stat.prompt);
881 wmove(status_bar, 0, input_stat.curs_pos);
893 wmove(status_bar, input_stat.curs_pos/line_width,
894 input_stat.curs_pos%line_width);
882 895 } }
883 896
884 897 static void static void
 
... ... static void
1070 1083 update_cmdline(void) update_cmdline(void)
1071 1084 { {
1072 1085 int d; int d;
1073 input_stat.curs_pos = input_stat.prompt_wid
1074 + wcswidth(input_stat.line, input_stat.len);
1086 input_stat.curs_pos = input_stat.prompt_wid +
1087 wcswidth(input_stat.line, input_stat.len);
1075 1088 input_stat.index = input_stat.len; input_stat.index = input_stat.len;
1076 1089
1077 1090 d = (input_stat.prompt_wid + input_stat.len + 1 + line_width - 1)/line_width; d = (input_stat.prompt_wid + input_stat.len + 1 + line_width - 1)/line_width;
 
... ... insert_completed_command(struct line_stats *stat, const char *complete_command)
1259 1272 werase(status_bar); werase(status_bar);
1260 1273 mvwaddwstr(status_bar, 0, 0, stat->prompt); mvwaddwstr(status_bar, 0, 0, stat->prompt);
1261 1274 mvwaddwstr(status_bar, 0, stat->prompt_wid, stat->line); mvwaddwstr(status_bar, 0, stat->prompt_wid, stat->line);
1262 wmove(status_bar, 0, stat->curs_pos);
1275 wmove(status_bar, input_stat.curs_pos/line_width,
1276 input_stat.curs_pos%line_width);
1263 1277
1264 1278 return 0; return 0;
1265 1279 } }
 
... ... static void redraw_status_bar(struct line_stats *stat)
1561 1575 werase(status_bar); werase(status_bar);
1562 1576 mvwaddwstr(status_bar, 0, 0, stat->prompt); mvwaddwstr(status_bar, 0, 0, stat->prompt);
1563 1577 mvwaddwstr(status_bar, 0, stat->prompt_wid, stat->line); mvwaddwstr(status_bar, 0, stat->prompt_wid, stat->line);
1564 wmove(status_bar, 0, stat->curs_pos);
1578 wmove(status_bar, input_stat.curs_pos/line_width,
1579 input_stat.curs_pos%line_width);
1565 1580 } }
1566 1581
1567 1582 static size_t static size_t
File src/main_loop.c changed (mode: 100644) (index dd5116d29..2fdd2e27e)
... ... main_loop(void)
59 59 wtimeout(status_bar, KEYPRESS_TIMEOUT); wtimeout(status_bar, KEYPRESS_TIMEOUT);
60 60
61 61 update_stat_window(curr_view); update_stat_window(curr_view);
62 update_pos_window(view);
62 63
63 64 if(curr_view->selected_files) if(curr_view->selected_files)
64 65 { {
File src/modes.c changed (mode: 100644) (index 6843cab61..74544162d)
... ... modes_pre(void)
71 71 { {
72 72 if(mode == CMDLINE_MODE) if(mode == CMDLINE_MODE)
73 73 { {
74 touchwin(status_bar);
74 75 wrefresh(status_bar); wrefresh(status_bar);
75 76 return; return;
76 77 } }
 
... ... modes_post(void)
126 127 } }
127 128
128 129 if(curr_stats.show_full) if(curr_stats.show_full)
130 {
129 131 show_full_file_properties(curr_view); show_full_file_properties(curr_view);
132 }
130 133 else if(curr_view->list_rows > 0) else if(curr_view->list_rows > 0)
134 {
131 135 update_stat_window(curr_view); update_stat_window(curr_view);
136 update_pos_window(curr_view);
137 }
132 138
133 139 if(curr_stats.save_msg) if(curr_stats.save_msg)
134 140 ; ;
File src/ui.c changed (mode: 100644) (index d0db3669c..091eb464a)
... ... update_stat_window(FileView *view)
147 147 mvwaddstr(stat_win, 0, cur_x, id_buf); mvwaddstr(stat_win, 0, cur_x, id_buf);
148 148
149 149 wnoutrefresh(stat_win); wnoutrefresh(stat_win);
150 update_pos_window(view);
151 150 } }
152 151
153 152 /* /*
 
... ... redraw_window(void)
486 485 } }
487 486
488 487 update_stat_window(curr_view); update_stat_window(curr_view);
488 update_pos_window(curr_view);
489 489
490 490 if(curr_view->selected_files) if(curr_view->selected_files)
491 491 { {
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