Skip to content

Commit

Permalink
(mcview_new): use WRect to define a panel area.
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Borodin <[email protected]>
  • Loading branch information
aborodin committed Apr 7, 2024
1 parent d16ca7a commit fe47ac5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/filemanager/layout.c
Original file line number Diff line number Diff line change
Expand Up @@ -1196,7 +1196,7 @@ create_panel (int num, panel_view_mode_t type)
break;

case view_quick:
new_widget = WIDGET (mcview_new (r.y, r.x, r.lines, r.cols, TRUE));
new_widget = WIDGET (mcview_new (&r, TRUE));
the_other_panel = PANEL (panels[the_other].widget);
if (the_other_panel != NULL)
file_name = panel_current_entry (the_other_panel)->fname->str;
Expand Down
10 changes: 6 additions & 4 deletions src/viewer/mcviewer.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,16 +195,15 @@ mcview_mouse_callback (Widget * w, mouse_msg_t msg, mouse_event_t * event)
/* --------------------------------------------------------------------------------------------- */

WView *
mcview_new (int y, int x, int lines, int cols, gboolean is_panel)
mcview_new (const WRect * r, gboolean is_panel)
{
WRect r = { y, x, lines, cols };
WView *view;
Widget *w;

view = g_new0 (WView, 1);
w = WIDGET (view);

widget_init (w, &r, mcview_callback, mcview_mouse_callback);
widget_init (w, r, mcview_callback, mcview_mouse_callback);
w->options |= WOP_SELECTABLE | WOP_TOP_SELECT;
w->keymap = viewer_map;

Expand Down Expand Up @@ -243,6 +242,7 @@ mcview_viewer (const char *command, const vfs_path_t * file_vpath, int start_lin
WDialog *view_dlg;
Widget *vw, *b;
WGroup *g;
WRect r;

/* Create dialog and widgets, put them on the dialog */
view_dlg = dlg_create (FALSE, 0, 0, 1, 1, WPOS_FULLSCREEN, FALSE, NULL, mcview_dialog_callback,
Expand All @@ -252,7 +252,9 @@ mcview_viewer (const char *command, const vfs_path_t * file_vpath, int start_lin

g = GROUP (view_dlg);

lc_mcview = mcview_new (vw->rect.y, vw->rect.x, vw->rect.lines - 1, vw->rect.cols, FALSE);
r = vw->rect;
r.lines--;
lc_mcview = mcview_new (&r, FALSE);
group_add_widget_autopos (g, lc_mcview, WPOS_KEEP_ALL, NULL);

b = WIDGET (buttonbar_new ());
Expand Down
7 changes: 3 additions & 4 deletions src/viewer/mcviewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#define MC__VIEWER_H

#include "lib/global.h"
#include "lib/widget.h" /* WRect */

/*** typedefs(not structures) and defined constants **********************************************/

Expand Down Expand Up @@ -37,10 +38,8 @@ extern char *mcview_show_eof;

/*** declarations of public functions ************************************************************/

/* Creates a new WView object with the given properties. Caveat: the
* origin is in y-x order, while the extent is in x-y order. */
extern WView *mcview_new (int y, int x, int lines, int cols, gboolean is_panel);

/* Creates a new WView object with the given properties. */
extern WView *mcview_new (const WRect * r, gboolean is_panel);

/* Shows {file} or the output of {command} in the internal viewer,
* starting in line {start_line}.
Expand Down

0 comments on commit fe47ac5

Please sign in to comment.