1
0
forked from aniani/vim

updated for version 7.0c01

This commit is contained in:
Bram Moolenaar
2006-03-27 20:55:21 +00:00
parent 3991dab8e0
commit 2e2a2815e5
16 changed files with 146 additions and 69 deletions

View File

@@ -754,7 +754,7 @@
* GUI tabline
*/
#if defined(FEAT_WINDOWS) && (defined(FEAT_GUI_GTK) \
|| (defined(FEAT_GUI_MSWIN) && WINVER > 0x0400))
|| (defined(FEAT_GUI_MSWIN) && (!defined(_MSC_VER) || _MSC_VER > 1020)))
# define FEAT_GUI_TABLINE
#endif

View File

@@ -521,7 +521,7 @@ gui_init()
#ifndef FEAT_GUI_GTK
/* Set the shell size, adjusted for the screen size. For GTK this only
* works after the shell has been opened, thus it is further down. */
gui_set_shellsize(FALSE, TRUE);
gui_set_shellsize(FALSE, TRUE, RESIZE_BOTH);
#endif
#if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU)
/* Need to set the size of the menubar after all the menus have been
@@ -547,7 +547,7 @@ gui_init()
/* Give GTK+ a chance to put all widget's into place. */
gui_mch_update();
/* Now make sure the shell fits on the screen. */
gui_set_shellsize(FALSE, TRUE);
gui_set_shellsize(FALSE, TRUE, RESIZE_BOTH);
#endif
/* When 'lines' was set while starting up the topframe may have to be
* resized. */
@@ -741,7 +741,7 @@ gui_init_font(font_list, fontset)
#else
FALSE
#endif
);
, RESIZE_BOTH);
}
return ret;
@@ -1354,9 +1354,10 @@ gui_get_shellsize()
*/
/*ARGSUSED*/
void
gui_set_shellsize(mustset, fit_to_display)
gui_set_shellsize(mustset, fit_to_display, direction)
int mustset; /* set by the user */
int fit_to_display;
int direction; /* RESIZE_HOR, RESIZE_VER */
{
int base_width;
int base_height;
@@ -1399,14 +1400,14 @@ gui_set_shellsize(mustset, fit_to_display)
if (fit_to_display)
{
gui_mch_get_screen_dimensions(&screen_w, &screen_h);
if (width > screen_w)
if ((direction & RESIZE_HOR) && width > screen_w)
{
Columns = (screen_w - base_width) / gui.char_width;
if (Columns < MIN_COLUMNS)
Columns = MIN_COLUMNS;
width = Columns * gui.char_width + base_width;
}
if (height > screen_h)
if ((direction & RESIZE_VERT) && height > screen_h)
{
Rows = (screen_h - base_height) / gui.char_height;
check_shellsize();
@@ -1423,7 +1424,7 @@ gui_set_shellsize(mustset, fit_to_display)
# endif
gui_mch_set_shellsize(width, height, min_width, min_height,
base_width, base_height);
base_width, base_height, direction);
if (fit_to_display)
{
int x, y;
@@ -3087,9 +3088,7 @@ gui_menu_cb(menu)
}
#endif
#ifndef FEAT_WINDOWS
static int prev_which_scrollbars[3];
#endif
static int prev_which_scrollbars[3];
/*
* Set which components are present.
@@ -3203,7 +3202,7 @@ gui_init_which_components(oldval)
if (gui.in_use)
{
need_set_size = FALSE;
need_set_size = 0;
fix_size = FALSE;
#ifdef FEAT_GUI_TABLINE
@@ -3217,7 +3216,7 @@ gui_init_which_components(oldval)
i = Rows;
gui_update_tabline();
Rows = i;
need_set_size = TRUE;
need_set_size = RESIZE_VERT;
if (using_tabline)
fix_size = TRUE;
if (!gui_use_tabline())
@@ -3227,11 +3226,14 @@ gui_init_which_components(oldval)
for (i = 0; i < 3; i++)
{
if (gui.which_scrollbars[i] !=
/* The scrollbar needs to be updated when it is shown/unshown and
* when switching tab pages. But the size only changes when it's
* shown/unshown. Thus we need two places to remember whether a
* scrollbar is there or not. */
if (gui.which_scrollbars[i] != prev_which_scrollbars[i]
#ifdef FEAT_WINDOWS
curtab->tp_prev_which_scrollbars[i]
#else
prev_which_scrollbars[i]
|| gui.which_scrollbars[i]
!= curtab->tp_prev_which_scrollbars[i]
#endif
)
{
@@ -3245,16 +3247,20 @@ gui_init_which_components(oldval)
gui_do_scrollbar(wp, i, gui.which_scrollbars[i]);
}
}
need_set_size = TRUE;
if (gui.which_scrollbars[i])
fix_size = TRUE;
if (gui.which_scrollbars[i] != prev_which_scrollbars[i])
{
if (i == SBAR_BOTTOM)
need_set_size = RESIZE_VERT;
else
need_set_size = RESIZE_HOR;
if (gui.which_scrollbars[i])
fix_size = TRUE;
}
}
#ifdef FEAT_WINDOWS
curtab->tp_prev_which_scrollbars[i]
#else
prev_which_scrollbars[i]
curtab->tp_prev_which_scrollbars[i] = gui.which_scrollbars[i];
#endif
= gui.which_scrollbars[i];
prev_which_scrollbars[i] = gui.which_scrollbars[i];
}
#ifdef FEAT_MENU
@@ -3266,7 +3272,7 @@ gui_init_which_components(oldval)
gui_mch_enable_menu(gui.menu_is_active);
Rows = i;
prev_menu_is_active = gui.menu_is_active;
need_set_size = TRUE;
need_set_size = RESIZE_VERT;
if (gui.menu_is_active)
fix_size = TRUE;
}
@@ -3277,7 +3283,7 @@ gui_init_which_components(oldval)
{
gui_mch_show_toolbar(using_toolbar);
prev_toolbar = using_toolbar;
need_set_size = TRUE;
need_set_size = RESIZE_VERT;
if (using_toolbar)
fix_size = TRUE;
}
@@ -3287,7 +3293,7 @@ gui_init_which_components(oldval)
{
gui_mch_enable_footer(using_footer);
prev_footer = using_footer;
need_set_size = TRUE;
need_set_size = RESIZE_VERT;
if (using_footer)
fix_size = TRUE;
}
@@ -3307,7 +3313,7 @@ gui_init_which_components(oldval)
/* Adjust the size of the window to make the text area keep the
* same size and to avoid that part of our window is off-screen
* and a scrollbar can't be used, for example. */
gui_set_shellsize(FALSE, fix_size);
gui_set_shellsize(FALSE, fix_size, need_set_size);
#ifdef FEAT_GUI_GTK
/* GTK has the annoying habit of sending us resize events when
@@ -3379,7 +3385,7 @@ gui_update_tabline()
/* When the tabs change from hidden to shown or from shown to
* hidden the size of the text area should remain the same. */
if (!showit != !shown)
gui_set_shellsize(FALSE, showit);
gui_set_shellsize(FALSE, showit, RESIZE_VERT);
}
}

View File

@@ -159,7 +159,7 @@
#define TOOLBAR_BORDER_HEIGHT 12 /* room above+below buttons for MSWindows */
#ifdef FEAT_GUI_MSWIN
# define TABLINE_HEIGHT 24
# define TABLINE_HEIGHT 22
#endif
#if defined(NO_CONSOLE) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11)

View File

@@ -1041,7 +1041,7 @@ gui_mch_new_menu_font()
#endif
);
}
gui_set_shellsize(FALSE, TRUE);
gui_set_shellsize(FALSE, TRUE, RESIZE_VERT);
ui_new_shellsize();
if (oldpuller != None)
XFreePixmap(gui.dpy, oldpuller);
@@ -1418,7 +1418,7 @@ gui_mch_show_toolbar(int showit)
XtUnmanageChild(toolBar);
}
gui_set_shellsize(FALSE, FALSE);
gui_set_shellsize(FALSE, FALSE, RESIZE_VERT);
}

View File

@@ -1233,7 +1233,7 @@ gui_mch_new_menu_font()
#endif
);
}
gui_set_shellsize(FALSE, TRUE);
gui_set_shellsize(FALSE, TRUE, RESIZE_VERT);
ui_new_shellsize();
}
@@ -2799,7 +2799,7 @@ gui_mch_show_toolbar(int showit)
XtUnmanageChild(XtParent(toolBar));
}
gui_set_shellsize(FALSE, FALSE);
gui_set_shellsize(FALSE, FALSE, RESIZE_VERT);
}
/*

View File

@@ -692,13 +692,14 @@ gui_mch_set_winpos(int x, int y)
}
void
gui_mch_set_shellsize(width, height, min_width, min_height, base_width, base_height)
gui_mch_set_shellsize(width, height, min_width, min_height, base_width, base_height, direction)
int width; /* In OS units */
int height;
int min_width; /* Smallest permissable window size (ignored) */
int min_height;
int base_width; /* Space for scroll bars, etc */
int base_height;
int direction;
{
int s_width, s_height;
int block[] = {

View File

@@ -128,7 +128,7 @@ gui_mswin_get_menu_height(
if (fix_window && menu_height != old_menu_height)
{
old_menu_height = menu_height;
gui_set_shellsize(FALSE, FALSE);
gui_set_shellsize(FALSE, FALSE, RESIZE_VERT);
}
return menu_height;
@@ -488,7 +488,8 @@ gui_mch_init(void)
*/
void
gui_mch_set_shellsize(int width, int height,
int min_width, int min_height, int base_width, int base_height)
int min_width, int min_height, int base_width, int base_height,
int direction)
{
RECT workarea_rect;
int win_width, win_height;
@@ -528,16 +529,17 @@ gui_mch_set_shellsize(int width, int height,
;
/* if the window is going off the screen, move it on to the screen */
if (win_xpos + win_width > workarea_rect.right)
if ((direction & RESIZE_HOR) && win_xpos + win_width > workarea_rect.right)
win_xpos = workarea_rect.right - win_width;
if (win_xpos < workarea_rect.left)
if ((direction & RESIZE_HOR) && win_xpos < workarea_rect.left)
win_xpos = workarea_rect.left;
if (win_ypos + win_height > workarea_rect.bottom)
if ((direction & RESIZE_VERT)
&& win_ypos + win_height > workarea_rect.bottom)
win_ypos = workarea_rect.bottom - win_height;
if (win_ypos < workarea_rect.top)
if ((direction & RESIZE_VERT) && win_ypos < workarea_rect.top)
win_ypos = workarea_rect.top;
/* set window position */

View File

@@ -1113,14 +1113,18 @@ gui_mch_set_text_area_pos(int x, int y, int w, int h)
#if defined(FEAT_GUI_TABLINE)
if (showing_tabline)
{
int top = 0;
int top = 0;
RECT rect;
#ifdef FEAT_TOOLBAR
if (vim_strchr(p_go, GO_TOOLBAR) != NULL)
top = TOOLBAR_BUTTON_HEIGHT + TOOLBAR_BORDER_HEIGHT;
#endif
MoveWindow(s_tabhwnd, 0, top, w, TABLINE_HEIGHT, TRUE);
GetWindowRect(s_hwnd, &rect);
SetRect(&rect, 0, top, rect.right, TABLINE_HEIGHT);
TabCtrl_AdjustRect(s_tabhwnd, TRUE, &rect);
MoveWindow(s_tabhwnd, 0, top, rect.right, rect.bottom, TRUE);
}
#endif
@@ -2176,6 +2180,68 @@ gui_mch_show_toolbar(int showit)
#endif
#if defined(FEAT_GUI_TABLINE) || defined(PROTO)
static void
show_tabline_popup_menu(void)
{
HMENU tab_pmenu;
MENUITEMINFO minfo;
long rval;
POINT pt;
char_u string[3];
tab_pmenu = CreatePopupMenu();
if (tab_pmenu == NULL)
return;
minfo.cbSize = sizeof(MENUITEMINFO);
minfo.fMask = MIIM_TYPE|MIIM_ID;
minfo.fType = MFT_STRING;
minfo.dwTypeData = _("Close tab");
minfo.wID = TABLINE_MENU_CLOSE;
InsertMenuItem(tab_pmenu, TABLINE_MENU_CLOSE, FALSE, &minfo);
minfo.dwTypeData = _("New tab");
minfo.wID = TABLINE_MENU_NEW;
InsertMenuItem(tab_pmenu, TABLINE_MENU_NEW, FALSE, &minfo);
minfo.dwTypeData = _("Open tab...");
minfo.wID = TABLINE_MENU_OPEN;
InsertMenuItem(tab_pmenu, TABLINE_MENU_OPEN, FALSE, &minfo);
GetCursorPos(&pt);
rval = TrackPopupMenuEx(tab_pmenu, TPM_RETURNCMD, pt.x, pt.y, s_tabhwnd,
NULL);
DestroyMenu(tab_pmenu);
/* Add the string cmd into input buffer */
if (rval > 0)
{
TCHITTESTINFO htinfo;
int idx;
if (ScreenToClient(s_tabhwnd, &pt) == 0)
return;
htinfo.pt.x = pt.x;
htinfo.pt.y = pt.y;
idx = TabCtrl_HitTest(s_tabhwnd, &htinfo);
if (idx == -1)
idx = 0;
else
idx += 1;
string[0] = CSI;
string[1] = KS_TABMENU;
string[2] = KE_FILLER;
add_to_input_buf(string, 3);
string[0] = idx;
string[1] = (char_u)(long)rval;
add_to_input_buf_csi(string, 2);
}
}
/*
* Show or hide the tabline.
*/

View File

@@ -4899,7 +4899,7 @@ xim_instantiate_cb(display, client_data, call_data)
return;
xim_real_init(x11_window, x11_display);
gui_set_shellsize(FALSE, FALSE);
gui_set_shellsize(FALSE, FALSE, RESIZE_BOTH);
if (xic != NULL)
XUnregisterIMInstantiateCallback(x11_display, NULL, NULL, NULL,
xim_instantiate_cb, NULL);
@@ -4923,7 +4923,7 @@ xim_destroy_cb(im, client_data, call_data)
xic = NULL;
status_area_enabled = FALSE;
gui_set_shellsize(FALSE, FALSE);
gui_set_shellsize(FALSE, FALSE, RESIZE_BOTH);
XRegisterIMInstantiateCallback(x11_display, NULL, NULL, NULL,
xim_instantiate_cb, NULL);
@@ -4947,7 +4947,7 @@ xim_init()
if (xim_real_init(x11_window, x11_display))
return;
gui_set_shellsize(FALSE, FALSE);
gui_set_shellsize(FALSE, FALSE, RESIZE_BOTH);
#ifdef USE_X11R6_XIM
XRegisterIMInstantiateCallback(x11_display, NULL, NULL, NULL,
@@ -5162,7 +5162,7 @@ xim_real_init(x11_window, x11_display)
status_area_enabled = TRUE;
}
else
gui_set_shellsize(FALSE, FALSE);
gui_set_shellsize(FALSE, FALSE, RESIZE_BOTH);
}
else
{

View File

@@ -15,7 +15,7 @@ extern int gui_get_base_height __ARGS((void));
extern void gui_resize_shell __ARGS((int pixel_width, int pixel_height));
extern void gui_may_resize_shell __ARGS((void));
extern int gui_get_shellsize __ARGS((void));
extern void gui_set_shellsize __ARGS((int mustset, int fit_to_display));
extern void gui_set_shellsize __ARGS((int mustset, int fit_to_display, int direction));
extern void gui_new_shellsize __ARGS((void));
extern void gui_reset_scroll_region __ARGS((void));
extern void gui_start_highlight __ARGS((int mask));

View File

@@ -16,7 +16,7 @@ extern int gui_mch_open __ARGS((void));
extern void gui_mch_exit __ARGS((int rc));
extern int gui_mch_get_winpos __ARGS((int *x, int *y));
extern void gui_mch_set_winpos __ARGS((int x, int y));
extern void gui_mch_set_shellsize __ARGS((int width, int height, int min_width, int min_height, int base_width, int base_height));
extern void gui_mch_set_shellsize __ARGS((int width, int height, int min_width, int min_height, int base_width, int base_height, int direction));
extern void gui_mch_get_screen_dimensions __ARGS((int *screen_w, int *screen_h));
extern void gui_mch_settitle __ARGS((char_u *title, char_u *icon));
extern void gui_mch_enable_menu __ARGS((int showit));

View File

@@ -11,7 +11,7 @@ extern char_u *gui_mch_browse __ARGS((int saving, char_u *title, char_u *default
extern int gui_mch_dialog __ARGS((int type, char_u *title, char_u *message, char_u *buttons, int default_button, char_u *textfield));
extern int gui_mch_get_winpos __ARGS((int *x, int *y));
extern void gui_mch_set_winpos __ARGS((int x, int y));
extern void gui_mch_set_shellsize __ARGS((int width, int height, int min_width, int min_height, int base_width, int base_height));
extern void gui_mch_set_shellsize __ARGS((int width, int height, int min_width, int min_height, int base_width, int base_height, int direction));
extern void gui_mch_get_screen_dimensions __ARGS((int *screen_w, int *screen_h));
extern void gui_mch_iconify __ARGS((void));
extern void gui_mch_set_foreground __ARGS((void));

View File

@@ -59,7 +59,7 @@ extern char_u *gui_mch_browse __ARGS((int saving, char_u *title, char_u *dflt, c
extern int get_cmd_args __ARGS((char *prog, char *cmdline, char ***argvp, char **tofree));
extern void gui_mch_prepare __ARGS((int *argc, char **argv));
extern int gui_mch_init __ARGS((void));
extern void gui_mch_set_shellsize __ARGS((int width, int height, int min_width, int min_height, int base_width, int base_height));
extern void gui_mch_set_shellsize __ARGS((int width, int height, int min_width, int min_height, int base_width, int base_height, int direction));
extern void gui_mch_set_scrollbar_thumb __ARGS((scrollbar_T *sb, long val, long size, long max));
extern void gui_mch_set_font __ARGS((GuiFont font));
extern void gui_mch_set_fg_color __ARGS((guicolor_T color));

View File

@@ -61,7 +61,7 @@ extern int gui_is_win32s __ARGS((void));
extern void gui_mch_set_parent __ARGS((char *title));
extern void gui_mch_prepare __ARGS((int *argc, char **argv));
extern int gui_mch_init __ARGS((void));
extern void gui_mch_set_shellsize __ARGS((int width, int height, int min_width, int min_height, int base_width, int base_height));
extern void gui_mch_set_shellsize __ARGS((int width, int height, int min_width, int min_height, int base_width, int base_height, int direction));
extern void gui_mch_set_scrollbar_thumb __ARGS((scrollbar_T *sb, long val, long size, long max));
extern void gui_mch_set_font __ARGS((GuiFont font));
extern void gui_mch_set_fg_color __ARGS((guicolor_T color));

View File

@@ -1013,6 +1013,13 @@ extern char *(*dyn_libintl_textdomain)(const char *domainname);
#define WSP_BELOW 32 /* put new window below/right */
#define WSP_ABOVE 64 /* put new window above/left */
/*
* arguments for gui_set_shellsize()
*/
#define RESIZE_VERT 1 /* resize vertically */
#define RESIZE_HOR 2 /* resize horizontally */
#define RESIZE_BOTH 15 /* resize in both directions */
/*
* "flags" values for option-setting functions.
* When OPT_GLOBAL and OPT_LOCAL are both missing, set both local and global