Commit Graph

1925 Commits

Author SHA1 Message Date
Andrew Borodin
5a67afc812 (vfs_path_build_url_params_str): minor refactoring.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-06-02 12:49:13 +03:00
Andrew Borodin
9e039f66d1 (vfs_path_from_str_uri_parser): fix coding style.
(vfs_path_to_str_flags): likewise.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-06-02 12:49:13 +03:00
Andrew Borodin
482feccca8 (mc_search__glob_translate_to_regex): reduce variable scope, refactor.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-06-02 12:49:12 +03:00
Andrew Borodin
46ea5e2a99 Clarify handling of "#enc:".
* (vfs_canon): treate "#enc:" as a regular part of path in case of
    --disable-charset.
  * (realpath_test): likewise.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-06-02 12:41:34 +03:00
Andrew Borodin
8e55057fa3 (vfs_path_from_str_uri_parser): fixups.
Handle potential NULL argument.
Clarify detection of absolute path: handle a case when path starts
with #enc:.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-06-02 12:41:34 +03:00
Andrew Borodin
ab3e3339bb vfs_dirent: add new member d_len to get rid of d_name length calculation.
* (vfs_dirent_assign): set d_len up.
  * (mc_readdir): sync with new vfs_dirent: use d_len member.
  * (filename_completion_function): likewise.
  * (handle_dirent): likewise.
  * (find_ignore_dir_search): add 2nd argument to use length of
    directory name if it's known.
  * (do_search): sync with modified vfs_dirent and find_ignore_dir_search().
  * (NLENGTH): remove.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-06-02 12:41:34 +03:00
Andrew Borodin
f4183ed2f2 (filename_completion_function): use DIR_IS_DOT() macro.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-06-02 12:41:34 +03:00
Andrew Borodin
fc02bf666b (mc_g_string_append_c_len): new API that extends GString one.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-06-02 12:41:34 +03:00
Andrew Borodin
75ee44db20 Use listbox_add_item_take() in obvious cases.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-06-02 12:41:34 +03:00
Andrew Borodin
401cd4a16c (listbox_add_item_take): new WListbox API.
Add new item to a listbox taking ownerhip of item text
and avoid a string duplication.

(listbox_add_item): reimplement using listbox_add_item_take().

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-06-02 12:41:34 +03:00
Andrew Borodin
e496af7a1c input complete: reimplement using GPtrArray.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-06-02 12:41:32 +03:00
Andrew Borodin
4eacf0f99b (insert_text): constify argument.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-06-02 12:40:02 +03:00
Andrew Borodin
2ee620f74f Ticket #4292: fix redundant back slashes for autocomplete.
Steps to reproduce:

1. Create file owth a space in the name:
  touch "a b"
There should no other files with name begins with "a" in the directory.
2. Press Shift-F4 to open editor
3. Press Shift-F2 to display dialog window "Save as..."
4. Press Esc+Tab to fill an input line

Result:
a\ b will appear in the edit field.
If you attempt to save the file, the back slash will be in the filename.

Expected result:
no any extra back slashes in the file name.

Soution: escape only '?', '*', and '&' symbols as described in the
manual page (see a11995e12b).

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-05-19 19:30:07 +03:00
Andrew Borodin
2fda4c6670 Ticket #4535: change name of temporary drirectory.
* (mc_tmpdir): use g_mkdtemp() to create temporary directory.
  Make it name unique to avoid conflicts with other software such as
  Distrobox container.
  * (main): temporary directory has unique name from now. Remove it at exit.
2024-05-13 21:48:35 +03:00
Andrew Borodin
e6ae50191b (fetch_hosts): refactoring.
Reduce variablle scope.
Refactor loops.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-04-07 16:38:11 +03:00
Andrew Borodin
4929248f30 hostname complition: refactoring: use GPtrArray. 2024-04-07 16:38:11 +03:00
Andrew Borodin
1c7da890bf (load_codepages_list_from_file): use g_ptr_array_new_full().
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-04-07 16:38:11 +03:00
Andrew Borodin
1bae2c678f Move OS-specific stuff from lib/global.h to lib/unixcompat.h.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-04-07 16:38:11 +03:00
Andrew Borodin
a2f65852e3 Merge lib/utilunix.h into lib/util.h.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-04-07 16:38:11 +03:00
Andrew Borodin
aa38245e85 Merge lib/strescape.h into lib/strutil.h. Rename functions.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-04-07 16:38:11 +03:00
Andrew Borodin
9584973453 (mc_build_filenamev): refactoring.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-04-07 16:06:16 +03:00
Andrew Borodin
7af11660f8 Clean up irrelevant comments.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-04-07 16:01:47 +03:00
Andrew Borodin
44d8213f4e Ticket #4533: External editor does not work with arguments in $EDITOR
When using an external editor (i.e. "Use internal edit" in the Configure
Options is unchecked) the environment variable EDITOR is used. However,
if $EDITOR contains a command line argument after the executable name,
these arguments are not processed properly, and the editor might not be
started at all.

How to reproduce: (Precondition: vi is available on the system)
  1) On the command line, execute: export EDITOR="vi +" && mc
(the + argument should let vi start at the document's end instead of the
beginning).
  2) Go to the Options menu -> Configuration -> uncheck "Use internal
edit".
  3) Move the cursor to a file that is larger than a single screen (e.g.
ABOUT-NLS in mc's source directory).
  4) Press F4 to start the external editor.

Result: Nothing visible happens

Expected result: vi is opened showing the end of the file ABOUT-NLS

The bug: my_system_make_arg_array() doesn't perform full-feature
parsing of the comman line.

  * (str_tokenize): mew function based on history_tokenize_internal()
from GNU readline-8.2.
  * (str_tokenize_word): mew function based on history_tokenize_word()
from GNU readline-8.2.
  * (my_system_make_arg_array): reimplement using str_tokenize().
  * (my_systemv_flags): use modified my_system_make_arg_array().
  * (fork_child_tokens): new test for string tokenization.
  * (fork_child_tokens2): likewise.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-03-31 19:04:26 +03:00
Andrew Borodin
fe42478b97 Update copyright years.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-01-01 09:46:17 +03:00
Andrew Borodin
07db4c4fa3 Refactor learn keys.
* (learn_store_key):
  * (learn_key): use GString for key buffer.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-12-31 19:28:44 +03:00
Andrew Borodin
2d86b8889f Use g_string_new_take().
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-12-31 19:28:44 +03:00
Andrew Borodin
247d092217 (str_utf8_offset_to_pos): change type of variable.
GString is pointless here.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-12-31 19:28:44 +03:00
Andrew Borodin
2e33fd4fad (mc_search_regex__get_max_num_of_replace_tokens): refactor loop.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-12-31 19:28:44 +03:00
Andrew Borodin
85b1cec81e lib/widget/input_complete.c: remove intermediate variables.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-12-31 19:28:44 +03:00
Andrew Borodin
94daff9071 (menubar_execute_cmd): move CK_Help handler to separate function menubar_help().
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-12-31 19:28:44 +03:00
Andrew Borodin
20dd30ada3 (dlg_execute_cmd): move CK_Help handler to separate function dlg_help().
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-12-31 19:28:44 +03:00
Andrew Borodin
1b3684e0e1 Ticket #4433: skins: add color for non-printable characters in editor.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-12-10 17:47:07 +03:00
TobiasW
f78f9b2eda Ticket #4509: support for lzo/lzop compression format.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-11-26 17:27:11 +03:00
Andrew Borodin
7459861f58 (mc_config_history_save): remove check because condition is always true here.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-11-06 21:06:15 +03:00
Andrew Borodin
a74d638155 (mc_config_history_get_recent_item): new API.
* (edit_search_cmd): use mc_config_history_get_recent_item().
  * (mcview_continue_search_cmd): likewise.

mc_config_history_get_recent_item() is not implemented optimally yet.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-11-06 21:06:15 +03:00
Andrew Borodin
018687b12f Fix comments of history and panels.ini files location.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-11-06 21:06:15 +03:00
Andrew Borodin
6b274f7034 lib/mcconfig/history.c: fix comments.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-11-06 21:06:15 +03:00
Andrew Borodin
d4e59aa022 Refactoring: avoid create an empty strings.
* (name_quote): return NULL instead of an empty string.
  * (fake_name_quote): likewise.
  * (expand_format): likewise.
  * Related changes.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-11-06 21:06:14 +03:00
Andrew Borodin
293fdafaa7 (str_8bit_casecmp, str_8bit_ncasecmp): refactor loops.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-11-06 21:06:14 +03:00
Andrew Borodin
771f6911a0 (str_8bit_casecmp, str_8bit_ncasecmp): reduce variable scope.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-11-06 21:06:14 +03:00
Andrew Borodin
2edbf44dc0 (tty_color_get_name_by_index): fix format overflow.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-11-06 21:06:14 +03:00
Andrew Borodin
1c81987cf6 (load_codepages_list_from_file): fix memory leak in free_codepages_list().
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-11-06 21:06:14 +03:00
Andrew Borodin
56f31e03ff Bump minimum GLib requirenment to 2.32.0.
This is required for g_array_set_clear_func().

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-11-06 21:06:14 +03:00
Andrew Borodin
1821e0e2f8 (vfs_path_build_url_params_str): return NULL instead of an empty string.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-11-06 21:06:13 +03:00
Andrew Borodin
5d8399befb tty: refactoring of color pairs deallocation.
* (tty_color_free_all_tmp): rename to tty_color_free_temp and call
    g_hash_table_foreach_remove().
  * (tty_color_free_all_non_tmp): rename to tty_color_free_all and call
    g_hash_table_remove_all().
  * (tty_color_free_all): remove.
  * (tty_color_free_condition_cb): rename to tty_color_free_temp_cb and
    simplify.
  * (mc_skin_deinit): use changed API.
  * (edit_free_syntax_rules): likewise.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-11-06 21:06:13 +03:00
Andrew Borodin
2d6d8a477e tty: color-related API changes
* (tty_try_alloc_color_pair): remove.
  * (tty_try_alloc_color_pair2): rename to tty_try_alloc_color_pair,
  change arguments.
  * (tty_color_set_defaults): changes arguments.
  * (this_try_alloc_color_pair): likewise.
  * lib/skin/color.c: related changes.
  * src/editor/syntax.c: likewise.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-11-06 21:06:13 +03:00
Andrew Borodin
c76c6820e6 lib/tty/color.c: use variable of tty_color_pair_t type for default color pair.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-11-06 21:06:13 +03:00
Andrew Borodin
4a116608d4 tty: refactoring of color pairs definition.
Rename structure mc_skin_color_t -> tty_color_pair_t and move to lib/tty/color.h.
Rename members.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-11-06 21:06:13 +03:00
Andrew Borodin
2c01bd53cb Ticket #4490: code cleanup before 4.8.31 release.
tty: refactoring of color pairs definition.

Rename structure tty_color_pair_t -> tty_color_lib_pair_t. Rename members.
Rename tty_color_try_alloc_pair_lib() -> tty_color_try_alloc_lib_pair().

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-11-06 21:06:13 +03:00
Andrew Borodin
6ca4ab4b4e Rename FISH VFS to SHELL one. 2023-10-15 16:04:39 +03:00