Browse Source

(edit_init): change argument for coordinates.

Use WRect instead of four values.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Andrew Borodin 2 years ago
parent
commit
12543835f9
4 changed files with 10 additions and 11 deletions
  1. 1 2
      src/editor/edit-impl.h
  2. 3 6
      src/editor/edit.c
  3. 1 1
      src/editor/editwidget.c
  4. 5 2
      tests/src/editor/edit_complete_word_cmd.c

+ 1 - 2
src/editor/edit-impl.h

@@ -180,8 +180,7 @@ char *edit_get_write_filter (const vfs_path_t * write_name_vpath,
                              const vfs_path_t * filename_vpath);
 gboolean edit_save_confirm_cmd (WEdit * edit);
 gboolean edit_save_as_cmd (WEdit * edit);
-WEdit *edit_init (WEdit * edit, int y, int x, int lines, int cols,
-                  const vfs_path_t * filename_vpath, long line);
+WEdit *edit_init (WEdit * edit, const WRect * r, const vfs_path_t * filename_vpath, long line);
 gboolean edit_clean (WEdit * edit);
 gboolean edit_ok_to_exit (WEdit * edit);
 gboolean edit_load_cmd (WDialog * h);

+ 3 - 6
src/editor/edit.c

@@ -2081,8 +2081,7 @@ edit_insert_file (WEdit * edit, const vfs_path_t * filename_vpath)
  */
 
 WEdit *
-edit_init (WEdit * edit, int y, int x, int lines, int cols, const vfs_path_t * filename_vpath,
-           long line)
+edit_init (WEdit * edit, const WRect * r, const vfs_path_t * filename_vpath, long line)
 {
     gboolean to_free = FALSE;
 
@@ -2106,14 +2105,13 @@ edit_init (WEdit * edit, int y, int x, int lines, int cols, const vfs_path_t * f
     }
     else
     {
-        WRect r = { y, x, lines, cols };
         Widget *w;
 
         edit = g_malloc0 (sizeof (WEdit));
         to_free = TRUE;
 
         w = WIDGET (edit);
-        widget_init (w, &r, NULL, NULL);
+        widget_init (w, r, NULL, NULL);
         w->options |= WOP_SELECTABLE | WOP_TOP_SELECT | WOP_WANT_CURSOR;
         w->keymap = editor_map;
         w->ext_keymap = editor_x_map;
@@ -2246,8 +2244,7 @@ edit_reload_line (WEdit * edit, const vfs_path_t * filename_vpath, long line)
     e->fullscreen = edit->fullscreen;
     e->loc_prev = edit->loc_prev;
 
-    if (edit_init (e, w->rect.y, w->rect.x, w->rect.lines, w->rect.cols, filename_vpath, line) ==
-        NULL)
+    if (edit_init (e, &w->rect, filename_vpath, line) == NULL)
     {
         g_free (e);
         return FALSE;

+ 1 - 1
src/editor/editwidget.c

@@ -1384,7 +1384,7 @@ edit_add_window (WDialog * h, const WRect * r, const vfs_path_t * f, long fline)
     WEdit *edit;
     Widget *w;
 
-    edit = edit_init (NULL, r->y, r->x, r->lines, r->cols, f, fline);
+    edit = edit_init (NULL, r, f, fline);
     if (edit == NULL)
         return FALSE;
 

+ 5 - 2
tests/src/editor/edit_complete_word_cmd.c

@@ -6,7 +6,7 @@
 
    Written by:
    Slava Zanko <slavazanko@gmail.com>, 2013
-   Andrew Borodin <aborodin@vmail.ru>, 2021
+   Andrew Borodin <aborodin@vmail.ru>, 2021-2022
 
    This file is part of the Midnight Commander.
 
@@ -151,6 +151,8 @@ edit_completion_dialog_show__deinit (void)
 static void
 my_setup (void)
 {
+    WRect r;
+
     str_init_strings (NULL);
 
     vfs_init ();
@@ -168,7 +170,8 @@ my_setup (void)
 
     option_filesize_threshold = (char *) "64M";
 
-    test_edit = edit_init (NULL, 0, 0, 24, 80, vfs_path_from_str ("test-data.txt"), 1);
+    rect_init (&r, 0, 0, 24, 80);
+    test_edit = edit_init (NULL, &r, vfs_path_from_str ("test-data.txt"), 1);
     memset (&owner, 0, sizeof (owner));
     group_add_widget (&owner, WIDGET (test_edit));
     edit_completion_dialog_show__init ();