Commit Graph

15627 Commits

Author SHA1 Message Date
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
Andrew Borodin
be16d3a747 Ticket #4444: mc.ext.ini: .md files are not recognized as Markdown ones by extension.
Change ShellIgnoreCase key to RegexIgnoreCase one since the Regex key
is used.
Simplify Regex value.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-02-17 21:36:28 +03:00
Pavel Roskin
a6fc94f294 Ticket #4441: skin julia256.ini: Fix visual inconsistencies.
Set "disabled" background to "lightgray" for consistency with the dialog
background. The inconsistent background can be seen in the file search dialog
with an empty search string.

The hotkeys in dialogs were impossible to distinguish from other text. Make
them red for consistency with the buttonbar.

Show changed lines in diffs in black on cyan. Blue on cyan is hard to see,
such color combination is not used elsewhere in the skin, which promises
"good contrast".

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-02-12 13:37:22 +03:00
Andrew Borodin
cce50e5bff Ticket #4432: wrong sort order after swapping panels.
Revert "(swap_panels): swap panel sort modes too."

This reverts commit d07abec4c3.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-02-01 20:55:28 +03:00
Andrew Borodin
8a91de70c4 Merge branch '4426_cleanup'
* 4426_cleanup: (49 commits)
  ru/mc.1: fix typo.
  doc/NEWS: indentation.
  Update po/*.po files.
  Ticket #4437: (file_frmt_time): fix time format.
  mcedit: use diff syntax highlighting for git commit messages
  (load_extension_file): make one-line long error messages multi-line.
  mc.ext.ini.in: fix a typo (closes MidnightCommander/mc#178).
  Filehighlight: recognize vsix files as zip files (closes MidnightCommander/mc#171).
  mcedit: support modern ECMAScript syntax in TypeScript (closes MidnightCommander/mc#172).
  Aadd syntax highlighting for modern ECMAScript (closes MidnightCommander/mc#172).
  extfs helpers: replace "perl -w" with "use warnings" (closes MidnightCommander/mc#174).
  (do_find): use dir_list_append() to create file list for panelization.
  (do_find): remove unused variable.
  Fix various typos in the source code (closes MidnightCommander/mc#177).
  (panel_destroy): don't free file list.
  (search_content): use g_get_monotonic_time() instead of g_get_real_time().
  (extfs_get_plugins): minor optimization.
  (edit_read_syntax_rules): trivial refactoring.
  mcedit (syntax): minor optimization.
  src/filemanager/panelize.c: use GSList to hold panelize entries.
  ...
2023-01-29 11:25:45 +03:00
Andrew Borodin
8279b4b7e8 ru/mc.1: fix typo.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-01-29 11:24:50 +03:00
Andrew Borodin
cefc35e924 doc/NEWS: indentation.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-01-29 11:21:23 +03:00
Andrew Borodin
706f7894db Update po/*.po files.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-01-29 11:17:20 +03:00
Andrew Borodin
3937f97d96 Ticket #4437: (file_frmt_time): fix time format.
Change minutes and seconds delimiter: h:mm.ss -> h:mm:ss.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-01-28 21:38:05 +03:00
JJ Andresson
9ad896f5e7 mcedit: use diff syntax highlighting for git commit messages
...when GIT_EDITOR=mcedit (closes MidnightCommander/mc#85).

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-01-28 21:38:05 +03:00
Andrew Borodin
08c2d4e276 (load_extension_file): make one-line long error messages multi-line.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-01-28 21:38:05 +03:00
Mariusz Białończyk
c84f9b0536 mc.ext.ini.in: fix a typo (closes MidnightCommander/mc#178).
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-01-28 21:38:05 +03:00
Sorin Sbarnea
93fed656bc Filehighlight: recognize vsix files as zip files (closes MidnightCommander/mc#171).
vsix files are vscode code plugins and they just zip archives, so
it makes sense to recognize them as alternative zip file extension.

Signed-off-by: Sorin Sbarnea <ssbarnea@redhat.com>
Signed-off-by: Yury V. Zaytsev <yury.zaytsev@moneymeets.com>
2023-01-28 21:38:05 +03:00
Timur Shemsedinov
4c287bb73e mcedit: support modern ECMAScript syntax in TypeScript (closes MidnightCommander/mc#172).
Signed-off-by: Timur Shemsedinov <timur.shemsedinov@gmail.com>
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2023-01-28 21:38:05 +03:00
Timur Shemsedinov
1d1c37834a Aadd syntax highlighting for modern ECMAScript (closes MidnightCommander/mc#172).
Signed-off-by: Timur Shemsedinov <timur.shemsedinov@gmail.com>
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2023-01-28 21:38:05 +03:00
Robert Yang
6123946251 extfs helpers: replace "perl -w" with "use warnings" (closes MidnightCommander/mc#174).
The shebang's max length is usually 128 as defined in
/usr/include/linux/binfmts.h:
  #define BINPRM_BUF_SIZE 128

To get around this, '/usr/bin/env perl' in place of @PERL@ can be used, but
'/usr/bin/env perl -w' doesn't work:

/usr/bin/env: perl -w: No such file or directory

So replace "perl -w" with "use warnings" to make it work.

The man2hlp.in already has "use warnings;", so just removing '-w' is OK.

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2023-01-28 21:38:05 +03:00