Commit Graph

522 Commits

Author SHA1 Message Date
Andrew Borodin
6718b3ec26 Indentation using GNU indent-2.2.13.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-06-02 12:49:13 +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
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
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
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
fe42478b97 Update copyright years.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2024-01-01 09:46:17 +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
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
f1cf92f435 Indentation.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-08-04 21:04:55 +03:00
Andrew Borodin
ee5bf223fb (hotkey_draw): constify argument.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-08-04 21:04:55 +03:00
Andrew Borodin
d243d467a8 (widget_selectcolor): constify argument.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-08-04 21:04:55 +03:00
Andrew Borodin
afaa3f075a lib/widget/quick.h: remove unneeded #include.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-08-04 21:04:54 +03:00
Andrew Borodin
702c3634e5 Move the some stuff from dialog.[ch] to dialog-switch.[ch]:
* variables: top_dlg, fast_refresh;
  * function: do_refresh().

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-08-04 21:04:54 +03:00
Andrew Borodin
fc6cc7bfc3 lib/widget/widget-common.h: rename include guard.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-08-04 21:04:54 +03:00
Andrew Borodin
ea40129743 Menu: renames:
WMenuBar::selected -> WMenuBar::current
  menu_t::selected -> menu_t::current

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-08-04 21:04:54 +03:00
Andrew Borodin
35b5d8e2f2 WListbox: renames:
WListbox::pos -> WListbox::current
  listbox_select_entry() -> listbox_set_current()
  listbox_get_nth_item() -> listbox_get_nth_entry()

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-08-04 21:04:54 +03:00
Andrew Borodin
e6cb6591b3 (dlg_close): rename from dlg_stop().
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-08-04 21:04:11 +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
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
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
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
Kian-Meng Ang
5001232704 Fix various typos in the source code (closes MidnightCommander/mc#177).
Found via `codespell -S
po,doc,./misc/syntax,./src/vfs/extfs/helpers/README.it -L
parm,rouge,sav,ect,vie,te,dum,clen,wee,dynamc,childs,ths,fo,nin,unx,nd,iif,iterm,ser,makrs,wil`

Co-authored-by: Yury V. Zaytsev <yury@shurup.com>
Signed-off-by: Kian-Meng Ang <kianmeng@cpan.org>
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
2023-01-28 21:38:05 +03:00
Andrew Borodin
57c61b7681 Update copyright years.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-01-28 21:38:05 +03:00
Andrew Borodin
b3fb596040 (dlg_init): get rid of extra dialog draws.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-01-28 21:38:04 +03:00
Andrew Borodin
3a3171c990 (widget_default_set_state): clarify set of widget state's exclusive bits.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-01-28 21:38:04 +03:00
Andrew Borodin
fbfb4f565c (menubar_new): do not reset WOP_SELECTABLE options
...because widget is not selectable by default.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-01-28 21:38:04 +03:00
Andrew Borodin
1e9f0d6d69 (buttonbar_new): set options directly.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-01-28 21:38:04 +03:00
Andrew Borodin
2a80ea54dd (widget_init): remove double assignments.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-01-28 21:38:04 +03:00
Andrew Borodin
7031508550 (command_completion_function): don't call canonicalize_pathname()
...because mc_build_filename() makes that.

(etags_set_definition_hash): likewise.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-01-28 21:38:04 +03:00
Andreas Mohr
1431d8b692 (ins_from_clip): fix maybe-uninitialized warning.
../../../lib/widget/input.c:573:8: error: 'event_data.ret' may be used uninitialized [-Werror=maybe-uninitialized]
  573 |     if (event_data.ret)
      |        ^
../../../lib/widget/input.c:566:35: note: 'event_data.ret' was declared here
  566 |     ev_clipboard_text_from_file_t event_data;

Found by gcc-11.

Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-10-10 21:07:40 +03:00
Andrew Borodin
79645187c6 (input_get_ctext): mew API.
Use it instead of direct access to WInput's buffer.

(handle_cmdline_enter): additional minor refactoring.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-08-04 11:17:29 +03:00
Andrew Borodin
28154dc520 (input_destroy): remove check if WInput object is NULL. This object must exist.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-08-04 11:11:50 +03:00
Andrew Borodin
589155f6bf WInput: make one-line APIs inline.
* (input_get_text): make inline.
  * (input_is_empty): likewise.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-08-04 11:11:33 +03:00
Andrew Borodin
4e245291b4 (input_is_empty): remove checks. WInput object must exist.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-08-04 11:09:49 +03:00
Andrew Borodin
318315399b Ticket #4397: sort in editor without arguments stopped working.
* (input_get_text): never return NULL. If buffer is empty, return an
empty allocated string.
  * (input_push_history): use new input_get_text.
  * (find_parameters): likewise.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-08-04 11:09:42 +03:00
Andrew Borodin
6c45208744 Fix indentation.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-06-05 20:12:46 +03:00
Andrew Borodin
101714e39b (query_default_callback): clarify widget position.
If dialog should be placed too high (in the upper half of the screen
closer to the screen top), show it centered.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-06-05 12:19:47 +03:00
Andrew Borodin
caf41457c6 (widget_adjust_position): change argument for coordinates.
Use WRect instead of four values.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-06-05 11:55:06 +03:00
Andrew Borodin
390d614b5e (group_init): change argument for coordinates.
Use WRect instead of four values.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2022-06-05 11:55:06 +03:00