Commit Graph

1018 Commits

Author SHA1 Message Date
Andrew Borodin d0955f3793 Search callbacks should return mc_search_cbret_t not int.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2013-06-03 14:21:03 +03:00
Andrew Borodin 3662b84ba1 (vfs_get_encoding): optimization and enhancement:
* get rid of extra memory duplication;
  * support of recursive search of correct encoding;
  * add tests.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2013-06-03 14:21:02 +03:00
Andrew Borodin 6b90a1468a (button_set_text): update value of WButton::hotpos.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2013-06-03 14:21:02 +03:00
Andrew Borodin 6d31d85f0d Use tty_draw_box instead of draw_box() to draw frames.
* (draw_box): remove.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2013-06-03 14:21:02 +03:00
Slava Zanko 2640b21bb9 Remove vfs_path_to_str() function for avoid often memory allocations.
Signed-off-by: Slava Zanko <slavazanko@gmail.com>
2013-06-03 14:21:01 +03:00
Andrew Borodin 31bacf56c9 Use G_N_ELEMENTS macro to calculate of array size.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2013-06-03 10:58:14 +03:00
Slava Zanko 80c8d58003 remove the include duplicates from source files
Signed-off-by: Slava Zanko <slavazanko@gmail.com>
2013-06-03 10:58:14 +03:00
Denys Vlasenko 664e7d31b6 When we see an unknown sequence, it is not enough
to drop already received part - there can be more of it
coming over e.g. a serial line.

To prevent interpreting it as a random garbage,
eat and discard all chars that follow.
Small, but non-zero timeout is needed to reconnect
escape sequence split up by a serial line.

Before this change, Ctrl-Alt-Shift-Right_Arrow generates "1;8C"
bogus "input" in MC on my machine; after the change,
nothing is generated.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Signed-off-by: Slava Zanko <slavazanko@gmail.com>
2013-05-23 11:42:02 +03:00
Denys Vlasenko ecd3b62b8e This change prevents misinterpreting an unknown ESC sequence's
tail as a garbage input. To reproduce, run "sleep 3" and
hold down Down_Arrow key until sleep runs.
With debugging log enabled, the following can be seen:

entered get_key_code(no_delay:0)
 c=tty_lowlevel_getch()=27
 push_char(27) !0
 c=xgetch_second()=91
 push_char(91) !0
 2 c=tty_lowlevel_getch()=66
 push_char(66)
 seq_buffer[0]:27   <---- the saved Down Arrow sequence "ESC [ B"
 seq_buffer[1]:91
 seq_buffer[2]:66
 seq_buffer[3]:0
pending_keys!=NULL. m=-1
d=*pending_keys++=27
d=ALT(*pending_keys++)=ALT(91)=8283
^^^^^^^^^^^^^^^^^^^^^^^ we misinterpret "ESC [ B" as "ESC ["
return correct_key_code(8283)
entered get_key_code(no_delay:0)
pending_keys!=NULL. m=-1
d=*pending_keys++=66
^^^^^^^^^^^^ we think user pressed "B"
return correct_key_code(66)

With this patch, no bogus "input" is generated.

Longer unknown sequences need an additional fix, coming next.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Signed-off-by: Slava Zanko <slavazanko@gmail.com>
2013-05-23 11:42:02 +03:00
Denys Vlasenko 77cfaf03cb Ticket #2988: When an unknown key is pressed, it is interpreted as garbage.
keyboard input: simplify code, no logic changes

This change slightly simplifies and rearranges the code
in get_key_code(), reduces indentation levels there,
adds a few comments. The logic remains the same.

This is a preparatory patch for subsequent changes.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Signed-off-by: Slava Zanko <slavazanko@gmail.com>
2013-05-23 11:41:25 +03:00
Andrew Borodin f23f0613ec Ticket #2991: fix redraw of WLabel after text change.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2013-04-08 15:46:39 +04:00
Andrew Borodin 705afe88c0 (mc_config_new_or_override_file): minor optimization.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2013-03-09 16:04:51 +04:00
Andrew Borodin 30959e0b7d Clarify widget redraw in runtime.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2013-03-09 16:04:19 +04:00
Andrew Borodin ef94b84eaf (size_trunc_len): support automatic maximum unit for specified size.
Fix typos.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2013-03-09 16:04:19 +04:00
Andrew Borodin 9b0b017201 (input_update): minor optimization: don't call str_term_width2() twice.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2013-03-09 16:04:18 +04:00
Slava Zanko c984447f8e Rename vfs_path_cmp() to vfs_path_equals()
Signed-off-by: Slava Zanko <slavazanko@gmail.com>
2013-03-09 16:04:18 +04:00
Andrew Borodin 8454f12f8f Ticket #2954: fix typo: occured -> occurred.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2013-03-09 16:04:18 +04:00
Andrew Borodin e29d98336b Ticket #2971: mouse click below non-droppeddown menubar activates menu box.
How to reproduce:
1. Switch the "Drop down menus" option off.
2. Press F9 to activate menubar. Menu is not dropped.
3. Click somewhere below menubar, on one of the files in the directory
listing.

Buggy behavior: the corresponding "Left" or "File" etc. dropdown is
opened, and the mouse button is released, menu item under the mouse
cursor is activated.

Correct behavior: clicking with the mouse somewhere other than the
active menubar doesn't open dropdown menu, instead removes the focus from
menubar and acts on the actual item under the mouse pointer (such
as a filename in the panel).

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2013-03-05 16:51:52 +04:00
Slava Zanko 6447c76cca Implementation of getting last editing/viewing position of file.
Signed-off-by: Slava Zanko <slavazanko@gmail.com>
2013-02-16 17:40:37 +03:00
Slava Zanko 278178093e Add support of reading parameters for external editor/viewer from main config.
for example, the config file may contain strings:

[External editor or viewer parameters]
    vim = %filename +%lineno
    mcedit = %filename:%lineno

And these external editors will open a file at the previously saved position.

Signed-off-by: Slava Zanko <slavazanko@gmail.com>
2013-02-16 17:40:37 +03:00
Slava Zanko e50c3f8475 mc_config_get_string(): if default parameter is NULL, then no any config entities will be created
Signed-off-by: Slava Zanko <slavazanko@gmail.com>
2013-02-16 17:40:37 +03:00
Slava Zanko 5b63c39459 mc_config_get_string_raw(): if default parameter is NULL, then no any config entities will be created
Signed-off-by: Slava Zanko <slavazanko@gmail.com>
2013-02-16 17:40:37 +03:00
Slava Zanko 808988b1f1 Add lib/strutil/replace:str_replace_all() function.
Signed-off-by: Slava Zanko <slavazanko@gmail.com>
2013-02-16 17:40:37 +03:00
Slava Zanko 2406284762 Add function lib/utilunix.c:my_systemv_flags()
Signed-off-by: Slava Zanko <slavazanko@gmail.com>
2013-02-16 17:39:33 +03:00
Slava Zanko c2f030f2e8 Add new functions:
* int my_systeml (int flags, const char *shell, ...);
 * int my_systemv (const char *command, char *const argv[]);

Signed-off-by: Slava Zanko <slavazanko@gmail.com>
2013-02-16 17:39:33 +03:00
Slava Zanko 1535d12d43 Code refactoring: my_system was split by few functions.
Signed-off-by: Slava Zanko <slavazanko@gmail.com>
2013-02-16 17:39:33 +03:00
Slava Zanko d32fefee76 Ticket #2206: Add jump support to target line in some external editors
Added own wrapper for _exit() system call. Useful for testing.

Signed-off-by: Slava Zanko <slavazanko@gmail.com>
2013-02-16 17:39:32 +03:00
Andrew Borodin b66a1e0592 Code indentation.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2013-02-14 14:42:27 +04:00
Slava Zanko 5445133766 mc_search__translate_replace_glob_to_regex(): Avoid warnings
...if function is called with 'const char *' argument.

Signed-off-by: Slava Zanko <slavazanko@gmail.com>
2013-02-14 14:30:38 +04:00
Andrew Borodin d8340c30da Ticket #2626: special chars are not escaped in autocompletion of filenames.
Test case:
1. Create a file with name that contains some special chars:
   touch attachment.cgi?id=564208
2. Press F6.
3. Press a. Now only the 'a' letter is in input line.
4. Press Esc Tab Enter.
5a. Input line is filled by 'attachment.cgi?id=564208'...
5b. but 'attachment.cgi\?id=564208' is expected.
6. Add 'patch_' before file name:
   'patch_attachment.cgi?id=564208'.
7. Press Enter.
8a. Result: 'patch_attachment.cgiattachment.cgi?id=564208id=564208'.
8b. Expected result: 'patch_attachment.cgi?id=564208'.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2013-02-14 14:30:38 +04:00
Andrew Borodin a11628da62 Ticket #2964: mouse doesn't select text in subshell in native console.
Steps to Reproduce:

1. Run mc in native console (not in X terminal emulator).
2. Press Ctrl+O to switch to subshell.
3. Try select anything with mouse.
Result: mouse does't select anything.

This bug was introduced in 68468a25ac
commit.

Solution: make mouse initialization after initializaton of subshell.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2013-02-14 14:26:25 +04:00
Slava Zanko 0f9ca096a3 Code indentation
Signed-off-by: Slava Zanko <slavazanko@gmail.com>
2013-02-13 14:24:45 +03:00
Slava Zanko 7e115b3024 Code refactoring: removed unneeded 'go to' label.
Signed-off-by: Slava Zanko <slavazanko@gmail.com>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2013-02-13 14:18:57 +03:00
Egmont Koblinger 1515c9f152 Ticket #2956: Newer protocol for extended mouse clicks.
A followup extension, "SGR 1006" was invented by xterm, to overcome some
of the shortcomings of the previous one. It is becoming as widespread as
the previous one, and is likely to soon overtake it in popularity.

Note that most of the patch is just the removal of the huge complexity
introduced by the previous one. The previous extension didn't have a
unique prefix which made the whole parsing logic extremely complicated.
The new extension does have a unique prefix, so parsing becomes a piece
of cake. The code becomes much cleaner and much easier to maintain.

Signed-off-by: Slava Zanko <slavazanko@gmail.com>
2013-02-13 14:18:57 +03:00
Andrew Borodin 0608af276e lib/widget/input_complete.c: minor refactoring and optimization.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2013-02-04 15:48:21 +03:00
Slava Zanko f7109ab46b Fix for input completions with spaces in names.
Signed-off-by: Slava Zanko <slavazanko@gmail.com>
2013-02-04 15:48:21 +03:00
Andrew Borodin c308d5ed21 lib/widget/input_complete.c: refactoring:
* (filename_completion_function): use GString to ret rid of hand-made
  low-level memory allocation.
  * (variable_completion_function): likewise.
  * (hostname_completion_function): likewise.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2013-02-04 15:48:21 +03:00
Slava Zanko f866709186 Concretize the usage of autocompliting in different input fields.
Signed-off-by: Slava Zanko <slavazanko@gmail.com>
2013-02-04 15:48:21 +03:00
Slava Zanko 2d58735deb Extend QUICK_INPUT and QUICK_LABELED_INPUT macros for getting completion flags via parameters instead of using hardcoded value
Signed-off-by: Slava Zanko <slavazanko@gmail.com>
2013-02-04 15:29:15 +03:00
Slava Zanko 9935acea33 Ticket #55: savannah: tab completion vs. spaces and escaping
* Split big functions.
* Add unit tests

Signed-off-by: Slava Zanko <slavazanko@gmail.com>
2013-02-04 15:29:15 +03:00
Slava Zanko ee8aaf6181 Avoid compiler errors like: error: variable 'xxx' set but not used [-Werror=unused-but-set-variable]
Signed-off-by: Slava Zanko <slavazanko@gmail.com>
2013-01-17 15:21:35 +03:00
Andrew Borodin 6cd19ea6cb Remove irrelevant comments about file_date() function.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2013-01-16 14:34:34 +04:00
Andrew Borodin ae6e647845 (mc_global_t::shell): new member to store user's shell
...instead of global variable "shell".

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2013-01-16 14:34:11 +04:00
Andrew Borodin 33cac494c0 WHLine: allow draw text over horizontal line.
* (hline_set_text): new function.
  * (file_progress_show_total): use hline_set_text to show processed
  files counter.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2013-01-14 16:23:17 +04:00
Andrew Borodin 2176e5f283 Ticket #2076: make copy/move/delete progress dialog wider.
Initial step: get rid of hardcoded width of progress bar.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2013-01-14 16:23:17 +04:00
Andrew Borodin 161a5af516 Ticket #2111: allow pause in copy/move/delete file operation.
Initial step: if button callback retuns zero, don't close the dialog after
button press.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2012-12-21 13:37:39 +04:00
Andrew Borodin 5e070286b1 Indentation.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2012-12-20 16:22:23 +04:00
Andrew Borodin 30dbb79655 (del_widget): fix memory leak.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2012-12-20 15:35:35 +04:00
Andrew Borodin 0e5b483974 Portability: rename some str_class members
...to avoid conflict with global names.

On HP-UX, inttypes.h includes ctype.h through other dependencies, ctype.h
defines macros for various functions and these macros clash with entries
of "struct str_class".

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2012-12-20 15:35:35 +04:00
Mikulas Patocka b475e31255 Portability: ESC_CHAR is defined in /usr/include/langinfo.h in some systems
...so undefine it to avoid warning.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2012-12-20 15:35:35 +04:00