Commit Graph

15542 Commits

Author SHA1 Message Date
Andrew Borodin be3822cafa Merge branch '4426_cleanup'
* 4426_cleanup: (38 commits)
  Update po/*.po files.
  (edit_find_editor): rename from find_editor.
  Listbox window: rename functions.
  (buttonbar_find): rename from find_buttonbar.
  Menu: rename functions.
  (advanced_chown_cmd): use intermediate variables to make text more readable.
  Use mc_fgetflags() and mc_fsetflags() where needed.
  VFS: mc_fgetflags, mc_fsetflags: new APIs.
  Minor optimization of chown/chmod/chattr operations.
  (operate_single_file): clarify creation of file operation UI.
  (dlg_default_destroy): send MSG_DESTROY to the dialog itself
  Collect all editor options to structure.
  Add EDIT and CONST_EDIT macros.
  usermenu: clarify compilation w/o internal editor.
  src/editor/spell.c: add missed #include.
  Update template for .c files.
  (do_search): remove intermediate variable.
  (do_search): get rid of string duplication.
  Change WDialog::data from void* to union{void*, int}
  Don't create an empty string in WLabel objects.
  ...
2023-03-19 20:40:09 +03:00
Andrew Borodin acedeff17a Update po/*.po files.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:39:51 +03:00
Andrew Borodin a286f042d4 (edit_find_editor): rename from find_editor.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:24 +03:00
Andrew Borodin c157b048e5 Listbox window: rename functions.
create_listbox_window -> listbox_window_new
create_listbox_window_centered -> listbox_window_new_centered
run_listbox -> listbox_run
run_listbox_with_data -> listbox_run_with_data

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:24 +03:00
Andrew Borodin d9383ba8b3 (buttonbar_find): rename from find_buttonbar.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:24 +03:00
Andrew Borodin fd2d5b49ac Menu: rename functions.
menu_entry_create -> menu_entry_new
menu_separator_create -> menu_separator_new
create_menu -> menu_new
destroy_menu -> menu_free
find_menubar -> menubar_find

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:24 +03:00
Andrew Borodin a242e8b91f (advanced_chown_cmd): use intermediate variables to make text more readable.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:24 +03:00
Andrew Borodin 79c8a351ba Use mc_fgetflags() and mc_fsetflags() where needed.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:24 +03:00
Andrew Borodin 2a6580127a VFS: mc_fgetflags, mc_fsetflags: new APIs.
(mc_fgetflags): fgetflags(3) VFS wrapper.
(mc_fsetflags): fsetflags(3) VFS wrapper.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:24 +03:00
Andrew Borodin 50f4717f45 Minor optimization of chown/chmod/chattr operations.
(try_chmod): create filename when required.
(try_chown): likewise.
(try_advanced_chown): likewise.
(try_chattr): likewise.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:24 +03:00
Andrew Borodin 6329771fc0 (operate_single_file): clarify creation of file operation UI.
Create UI to show confirmation dialog in case of foreground operation
regardless of ENABLE_BACKGROUND.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:24 +03:00
Andrew Borodin 47da3a764a (dlg_default_destroy): send MSG_DESTROY to the dialog itself
...to avoid various memory leaks.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:24 +03:00
Andrew Borodin 8a951746b3 Collect all editor options to structure.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:24 +03:00
Andrew Borodin d2b9454f4b Add EDIT and CONST_EDIT macros.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:24 +03:00
Andrew Borodin 683122482b usermenu: clarify compilation w/o internal editor.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:24 +03:00
Andreas Mohr de1edb72f8 src/editor/spell.c: add missed #include.
Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:24 +03:00
Andrew Borodin 7257f794d2 Update template for .c files.
Add section for forward declarations of local functions. This section is
located before file scope variables because functions can be used in
strucutres (see find.c for example):

/*** forward declarations (file scope functions) *************************************************/

/* button callbacks */
static int start_stop (WButton * button, int action);
static int find_do_view_file (WButton * button, int action);
static int find_do_edit_file (WButton * button, int action);

/*** file scope variables ************************************************************************/

static struct
{
    ...
    bcback_fn callback;
} fbuts[] =
{
    ...
    { B_STOP, NORMAL_BUTTON, N_("S&uspend"), 0, 0, NULL, start_stop },
    ...
    { B_VIEW, NORMAL_BUTTON, N_("&View - F3"), 0, 0, NULL, find_do_view_file },
    { B_VIEW, NORMAL_BUTTON, N_("&Edit - F4"), 0, 0, NULL, find_do_edit_file }
};

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:24 +03:00
Andrew Borodin e1ff8d94e4 (do_search): remove intermediate variable.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:23 +03:00
Andrew Borodin c7f9329dcb (do_search): get rid of string duplication.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:23 +03:00
Andrew Borodin 584fb9815c Change WDialog::data from void* to union{void*, int}
...to use data of type other than pointer w/o extra type cast.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:23 +03:00
Andrew Borodin c5466cd494 Don't create an empty string in WLabel objects.
* (simple_status_msg_init_cb): pass NULL instead of "" to label_new()
    to get rid of an empty string duplication.
  * (advanced_chown_dlg_create): likewise.
  * (chown_dlg_create): likewise.
  * (dirsize_status_init_cb): likewise.
  * (file_op_context_create_ui): likewise.
  * (setup_gui): likewise.
  * (init_hotlist): likewise.
  * (init_learn): likewise.
  * (file_progress_show_source): pass NULL instead of "" to
    label_set_text() to get rid of an empty string duplication.
  * (file_progress_show_target): likewise.
  * (create_file_manager): pass NULL instead of 0 to label_new().

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:23 +03:00
Andrew Borodin e472f23c13 Don't NULLify objects by returned value of g_ptr_array_free().
g_ptr_array_free(obj, ...) returns a pointer (including NULL) to
obj->pdata, not to obj.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:23 +03:00
Andrei Stepanov 08a89a87aa doc/man/ru/mc.1.in: fix typos.
Closes MidnightCommander/mc#179.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:23 +03:00
Andrew Borodin 000c1f18e6 src/vfs/tar/tar.c: reorder routines.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:23 +03:00
Andrew Borodin ea93350506 (tar_decode_header): use offsetof().
Sync with GNU tar b8feb2b14247d76200fd53607d3613c82b6e5b81.

Access header->buffer + offsetof (struct posix_header, magic), instead
of header->header.magic, when reading or writing the OLDGNU_MAGIC
pattern. The code violates the C standard without this change, and GCC
warns about this if fortify checking is enabled. It's not a bug on
traditional (i.e., non-debugging) platforms, but it does violate the C
standard so it should be fixed. Problem originally reported by John
Emil Karlson in
<http://lists.gnu.org/archive/html/bug-tar/2010-04/msg00023.html>.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:23 +03:00
Andrew Borodin 4a17f02b21 (tar_skip_n_records): change type of n to off_t.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:23 +03:00
Andrew Borodin 4ae197e788 (tar_checksum): sync with GNU tar b5db9788306d45cd9432fda71236f07b8a214212.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:23 +03:00
Andrew Borodin c4e20d3176 src/vfs/tar/tar.c: rename header read status and values.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:23 +03:00
Andrew Borodin 8ce58eab7b src/vfs/tar/tar.c: reorder includes; add <sys/stat.h>.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:23 +03:00
Andrew Borodin a15b91b030 src/vfs/tar/tar.c: clean up.
Sync with GNU tar 33b63ebe94b8a2dc2cb8fb907d8b7c16591b05bc.

(struct extra_header): Removed unused structure.
(union block.extra_header): Removed unused member.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:23 +03:00
Andrew Borodin 8fdcbeed74 Move definition of file_entry_t to separate file.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:23 +03:00
Andrew Borodin cf223bec27 Use g_ptr_array_new_with_free_func() where reasonably.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:23 +03:00
Andrew Borodin 273fbd2afe mceditor: editbuffer: use g_ptr_array_new_full() to create text buffers.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:23 +03:00
Andrew Borodin 381dc8732b lib/filehighlight/ini-file-read.c: fix coding style.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:23 +03:00
Andrew Borodin fe89441f3d gl_POSIX_FALLOCATE: rename to POSIX_FALLOCATE.
Remove the gl_ prefix because this macro isn't from Gnulib.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:23 +03:00
Florian Weimer b7e4fb9ef6 Ticket #4438: autoconf: fix C99 compatibility issue in mc_GET_FS_INFO check.
Include <fcntl.h> for the declaration of posix_fallocate.  This
avoids an implicit function declaration and build issues with future
compilers.

Signed-off-by: Florian Weimer <fweimer@redhat.com>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:23 +03:00
Andrew Borodin 29f513cf58 File operations: get file operation from the file operation context descriptor.
* (file_mask_dialog): get file operation from the file operation context
descriptor.
  * (do_confirm_copy_move): likewise.
  * (operate_single_file): likewise.
  * (operate_one_file): likewise.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:23 +03:00
Andrew Borodin f25895280b (panel_operate): change type of save_cwd and save_dest to vfs_path_t
...to get rid of extra type conversions and memory allocations.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:23 +03:00
Andrew Borodin 3364b5772c Ticket #4426: code clean up before 4.8.30 release.
(panel_do_set_filter): fix indentation.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:34:23 +03:00
Andrew Borodin 1d845d0dc5 Merge branch '3121_empty_subshell_prompt'
* 3121_empty_subshell_prompt:
  Ticket #3121: don't clear subshell prompt during its reading.
2023-03-19 20:30:46 +03:00
Michal Sojka d71a9cd43a Ticket #3121: don't clear subshell prompt during its reading.
When using zsh with starship.rs prompt generator, MC sometimes fails
to show the subshell prompt. This is not deterministic. Sometimes the
prompt is shown and sometimes it isn't.

The reason is that the shell prints the prompt in multiple chunks. The
first chunk contains the "real" prompt and the second is an escape
sequence for enabling bracketed paste mode. If both chunks are read by
MC in a single invocation of read_subshell_prompt(), the prompt is
shown correctly. If, however, read_subshell_prompt() reads each chunk
in separate invocations (because the second chunk is not ready during
the first invocation), the prompt is not shown. More precisely, only
the bracketed paste mode escape sequence is shown as a prompt in MC.

This can be demonstrated with the following commands:

    export SHELL=$(which zsh)
    export ZDOTDIR=/tmp/zshdotdir
    export STARSHIP_CONFIG=/tmp/starship-test.toml
    mkdir -p "$ZDOTDIR"
    echo 'eval "$(starship init zsh)"' > "$ZDOTDIR/.zshrc"
    echo 'format = "XXXX: $directory$character"' > "$STARSHIP_CONFIG"
    mc

In my case, the prompt is usualy shown after mc start and it
disappears after changing a directory in mc. In that case, the prompt
is read() in the following two chunks:

- 63 bytes: \xd\x1b[0m\x1b[27m\x1b[24m\x1b[J\xd\xaXXXX: \x1b[1;36mmc/.git\x1b[0m \x1b[1;32m\xe2\x9d\xaf\x1b[0m \x1b[K
- 8 bytes: \x1b[?2004h

To fix the problem, we remove clearing of the prompt string in
read_subshell_prompt(). It is sufficient that the prompt is cleared
when receiving '\n' and in feed_subshell().

Signed-off-by: Michal Sojka <michal.sojka@cvut.cz>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-19 20:27:25 +03:00
Andrew Borodin ee76cb0ced Merge branch '4408_panels_redraw'
* 4408_panels_redraw:
  Ticket #4408: incorrect redraw of overlapped file panels.
2023-03-19 20:10:30 +03:00
Andrew Borodin 7e04a57b87 Ticket #4408: incorrect redraw of overlapped file panels.
Revert "(panel_operate): update panel content before screen refresh."

This reverts commit 6623a9014f.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-12 10:14:13 +03:00
Andrew Borodin 37ae744a50 Merge branch '4235_find_relative_ignore_dir'
* 4235_find_relative_ignore_dir:
  Ticket #4235: fix find file with relative ignore directory.
2023-03-05 19:53:30 +03:00
Andrew Borodin b4bb352bfa Ticket #4235: fix find file with relative ignore directory.
If start directory of find files matches to the relative ignore
directory, nothing is found.

(do_search): the start directory is the first one in the directory
stack. Do not apply ignore_dir to it.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-03-05 19:51:50 +03:00
Andrew Borodin b1f061e490 Merge branch '4446_paragraph_format'
* 4446_paragraph_format:
  Ticket #4446: mcedit: fix off-by-one error in paragraph formatting code.
2023-02-25 19:36:50 +03:00
Pavel Roskin 44c299c784 Ticket #4446: mcedit: fix off-by-one error in paragraph formatting code.
The default margin is 72 characters, but the editor would keep 73 character
long lines without breaking them.

The visual length of strings was calculated incorrectly. The way "for" loop
was implemented, the byte length would be incremented before exiting the
loop. That would correspond to a character that doesn't fit the line.

Increment the byte length in a separate statement.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-02-20 21:36:37 +03:00
Andrew Borodin 830ecf9780 Merge branch '4370_panelizations'
* 4370_panelizations:
  Ticket #4370: file panelization improvement.
2023-02-19 19:01:25 +03:00
Andrew Borodin e14ebea59f Ticket #4370: file panelization improvement.
Previously, both file panels share panelization results.
Now each file panel has own panelization buffer.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-02-19 19:00:59 +03:00
Pavel Roskin 1ad30a6474 Ticket #4445: skin julia256.ini: minor improvements.
Set "errdhotfocus" to a higher contrast color combination. Yellow is barely
visible on lightgray. The cursor stands on the the focused hotkey. If the
cursor is an underscore, the high contrast is obviously needed. If the focus
is a full box, it normally inverts both the background and the foreground, so
poor contrast remains poor. Red on lightgray is consistent with other colors
of the skin.

Set "menutitle" to yellow on blue. Otherwise, the title is not
distinguishable from the menu entries. Both "parent" skins, default and
xoria256, use distinctive color for the popup menu title.

Set "editrightmargin" to the same color as the panels. White on blue is
extremely distracting in contrast to black background to the left of the
margin.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-02-19 19:00:31 +03:00