summaryrefslogtreecommitdiffstats
path: root/src/gui_motif.c
diff options
context:
space:
mode:
authorYegappan Lakshmanan <yegappan@yahoo.com>2023-01-08 13:44:24 +0000
committerBram Moolenaar <Bram@vim.org>2023-01-08 13:44:24 +0000
commit7f8b2559a30e2e2a443c35b28e94c6b45ba7ae04 (patch)
tree04c0145c1e3cf9777d58c91fa7b2ad231cfecf8d /src/gui_motif.c
parentdf8f9473596c8fb18ec893de677dba455e8925b3 (diff)
patch 9.0.1158: code is indented more than necessaryv9.0.1158
Problem: Code is indented more than necessary. Solution: Use an early return where it makes sense. (Yegappan Lakshmanan, closes #11787)
Diffstat (limited to 'src/gui_motif.c')
-rw-r--r--src/gui_motif.c223
1 files changed, 111 insertions, 112 deletions
diff --git a/src/gui_motif.c b/src/gui_motif.c
index 55c026eb48..5e18f20c8e 100644
--- a/src/gui_motif.c
+++ b/src/gui_motif.c
@@ -979,14 +979,14 @@ gui_motif_add_actext(vimmenu_T *menu)
XmString label;
// Add accelerator text, if there is one
- if (menu->actext != NULL && menu->id != (Widget)0)
- {
- label = XmStringCreate((char *)menu->actext, STRING_TAG);
- if (label == NULL)
- return;
- XtVaSetValues(menu->id, XmNacceleratorText, label, NULL);
- XmStringFree(label);
- }
+ if (menu->actext == NULL || menu->id == (Widget)0)
+ return;
+
+ label = XmStringCreate((char *)menu->actext, STRING_TAG);
+ if (label == NULL)
+ return;
+ XtVaSetValues(menu->id, XmNacceleratorText, label, NULL);
+ XmStringFree(label);
}
void
@@ -1573,44 +1573,44 @@ gui_mch_destroy_menu(vimmenu_T *menu)
menu->submenu_id = (Widget)0;
}
- if (menu->id != (Widget)0)
- {
- Widget parent;
+ if (menu->id == (Widget)0)
+ return;
- parent = XtParent(menu->id);
+ Widget parent;
+
+ parent = XtParent(menu->id);
#if defined(FEAT_TOOLBAR) && defined(FEAT_BEVAL_GUI)
- if (parent == toolBar && menu->tip != NULL)
- {
- // We try to destroy this before the actual menu, because there are
- // callbacks, etc. that will be unregistered during the tooltip
- // destruction.
- //
- // If you call "gui_mch_destroy_beval_area()" after destroying
- // menu->id, then the tooltip's window will have already been
- // deallocated by Xt, and unknown behaviour will ensue (probably
- // a core dump).
- gui_mch_destroy_beval_area(menu->tip);
- menu->tip = NULL;
- }
+ if (parent == toolBar && menu->tip != NULL)
+ {
+ // We try to destroy this before the actual menu, because there are
+ // callbacks, etc. that will be unregistered during the tooltip
+ // destruction.
+ //
+ // If you call "gui_mch_destroy_beval_area()" after destroying
+ // menu->id, then the tooltip's window will have already been
+ // deallocated by Xt, and unknown behaviour will ensue (probably
+ // a core dump).
+ gui_mch_destroy_beval_area(menu->tip);
+ menu->tip = NULL;
+ }
#endif
- XtDestroyWidget(menu->id);
- menu->id = (Widget)0;
- if (parent == menuBar)
- gui_mch_compute_menu_height((Widget)0);
+ XtDestroyWidget(menu->id);
+ menu->id = (Widget)0;
+ if (parent == menuBar)
+ gui_mch_compute_menu_height((Widget)0);
#ifdef FEAT_TOOLBAR
- else if (parent == toolBar)
- {
- Cardinal num_children;
+ else if (parent == toolBar)
+ {
+ Cardinal num_children;
- // When removing last toolbar item, don't display the toolbar.
- XtVaGetValues(toolBar, XmNnumChildren, &num_children, NULL);
- if (num_children == 0)
- gui_mch_show_toolbar(FALSE);
- else
- gui.toolbar_height = gui_mch_compute_toolbar_height();
- }
-#endif
+ // When removing last toolbar item, don't display the toolbar.
+ XtVaGetValues(toolBar, XmNnumChildren, &num_children, NULL);
+ if (num_children == 0)
+ gui_mch_show_toolbar(FALSE);
+ else
+ gui.toolbar_height = gui_mch_compute_toolbar_height();
}
+#endif
}
void
@@ -1630,19 +1630,19 @@ gui_mch_show_popupmenu(vimmenu_T *menu UNUSED)
void
gui_mch_def_colors(void)
{
- if (gui.in_use)
- {
- gui.menu_fg_pixel = gui_get_color((char_u *)gui.rsrc_menu_fg_name);
- gui.menu_bg_pixel = gui_get_color((char_u *)gui.rsrc_menu_bg_name);
- gui.scroll_fg_pixel = gui_get_color((char_u *)gui.rsrc_scroll_fg_name);
- gui.scroll_bg_pixel = gui_get_color((char_u *)gui.rsrc_scroll_bg_name);
+ if (!gui.in_use)
+ return;
+
+ gui.menu_fg_pixel = gui_get_color((char_u *)gui.rsrc_menu_fg_name);
+ gui.menu_bg_pixel = gui_get_color((char_u *)gui.rsrc_menu_bg_name);
+ gui.scroll_fg_pixel = gui_get_color((char_u *)gui.rsrc_scroll_fg_name);
+ gui.scroll_bg_pixel = gui_get_color((char_u *)gui.rsrc_scroll_bg_name);
#ifdef FEAT_BEVAL_GUI
- gui.tooltip_fg_pixel =
- gui_get_color((char_u *)gui.rsrc_tooltip_fg_name);
- gui.tooltip_bg_pixel =
- gui_get_color((char_u *)gui.rsrc_tooltip_bg_name);
+ gui.tooltip_fg_pixel =
+ gui_get_color((char_u *)gui.rsrc_tooltip_fg_name);
+ gui.tooltip_bg_pixel =
+ gui_get_color((char_u *)gui.rsrc_tooltip_bg_name);
#endif
- }
}
@@ -1674,30 +1674,30 @@ gui_mch_set_scrollbar_pos(
int w,
int h)
{
- if (sb->id != (Widget)0)
+ if (sb->id == (Widget)0)
+ return;
+
+ if (sb->type == SBAR_LEFT || sb->type == SBAR_RIGHT)
{
- if (sb->type == SBAR_LEFT || sb->type == SBAR_RIGHT)
- {
- if (y == 0)
- h -= gui.border_offset;
- else
- y -= gui.border_offset;
- XtVaSetValues(sb->id,
- XmNtopOffset, y,
- XmNbottomOffset, -y - h,
- XmNwidth, w,
- NULL);
- }
+ if (y == 0)
+ h -= gui.border_offset;
else
- XtVaSetValues(sb->id,
- XmNtopOffset, y,
- XmNleftOffset, x,
- XmNrightOffset, gui.which_scrollbars[SBAR_RIGHT]
- ? gui.scrollbar_width : 0,
- XmNheight, h,
- NULL);
- XtManageChild(sb->id);
+ y -= gui.border_offset;
+ XtVaSetValues(sb->id,
+ XmNtopOffset, y,
+ XmNbottomOffset, -y - h,
+ XmNwidth, w,
+ NULL);
}
+ else
+ XtVaSetValues(sb->id,
+ XmNtopOffset, y,
+ XmNleftOffset, x,
+ XmNrightOffset, gui.which_scrollbars[SBAR_RIGHT]
+ ? gui.scrollbar_width : 0,
+ XmNheight, h,
+ NULL);
+ XtManageChild(sb->id);
}
int
@@ -1732,52 +1732,52 @@ gui_mch_enable_scrollbar(scrollbar_T *sb, int flag)
Arg args[16];
int n;
- if (sb->id != (Widget)0)
+ if (sb->id == (Widget)0)
+ return;
+
+ n = 0;
+ if (flag)
{
- n = 0;
- if (flag)
+ switch (sb->type)
{
+ case SBAR_LEFT:
+ XtSetArg(args[n], XmNleftOffset, gui.scrollbar_width); n++;
+ break;
+
+ case SBAR_RIGHT:
+ XtSetArg(args[n], XmNrightOffset, gui.scrollbar_width); n++;
+ break;
+
+ case SBAR_BOTTOM:
+ XtSetArg(args[n], XmNbottomOffset, gui.scrollbar_height);n++;
+ break;
+ }
+ XtSetValues(textArea, args, n);
+ XtManageChild(sb->id);
+ }
+ else
+ {
+ if (!gui.which_scrollbars[sb->type])
+ {
+ // The scrollbars of this type are all disabled, adjust the
+ // textArea attachment offset.
switch (sb->type)
{
case SBAR_LEFT:
- XtSetArg(args[n], XmNleftOffset, gui.scrollbar_width); n++;
+ XtSetArg(args[n], XmNleftOffset, 0); n++;
break;
case SBAR_RIGHT:
- XtSetArg(args[n], XmNrightOffset, gui.scrollbar_width); n++;
+ XtSetArg(args[n], XmNrightOffset, 0); n++;
break;
case SBAR_BOTTOM:
- XtSetArg(args[n], XmNbottomOffset, gui.scrollbar_height);n++;
+ XtSetArg(args[n], XmNbottomOffset, 0);n++;
break;
}
XtSetValues(textArea, args, n);
- XtManageChild(sb->id);
- }
- else
- {
- if (!gui.which_scrollbars[sb->type])
- {
- // The scrollbars of this type are all disabled, adjust the
- // textArea attachment offset.
- switch (sb->type)
- {
- case SBAR_LEFT:
- XtSetArg(args[n], XmNleftOffset, 0); n++;
- break;
-
- case SBAR_RIGHT:
- XtSetArg(args[n], XmNrightOffset, 0); n++;
- break;
-
- case SBAR_BOTTOM:
- XtSetArg(args[n], XmNbottomOffset, 0);n++;
- break;
- }
- XtSetValues(textArea, args, n);
- }
- XtUnmanageChild(sb->id);
}
+ XtUnmanageChild(sb->id);
}
}
@@ -1817,17 +1817,16 @@ gui_mch_create_scrollbar(
sb->id = XtCreateWidget("scrollBar",
xmScrollBarWidgetClass, textAreaForm, args, n);
+ if (sb->id == (Widget)0)
+ return;
- if (sb->id != (Widget)0)
- {
- gui_mch_set_scrollbar_colors(sb);
- XtAddCallback(sb->id, XmNvalueChangedCallback,
- scroll_cb, (XtPointer)sb->ident);
- XtAddCallback(sb->id, XmNdragCallback,
- scroll_cb, (XtPointer)sb->ident);
- XtAddEventHandler(sb->id, KeyPressMask, FALSE, gui_x11_key_hit_cb,
+ gui_mch_set_scrollbar_colors(sb);
+ XtAddCallback(sb->id, XmNvalueChangedCallback,
+ scroll_cb, (XtPointer)sb->ident);
+ XtAddCallback(sb->id, XmNdragCallback,
+ scroll_cb, (XtPointer)sb->ident);
+ XtAddEventHandler(sb->id, KeyPressMask, FALSE, gui_x11_key_hit_cb,
(XtPointer)0);
- }
}
void