示例#1
0
文件: gui_web.c 项目: CarolHsu/vim.js
/*
 * Initialise vim to use the font with the given name.	Return FAIL if the font
 * could not be loaded, OK otherwise.
 */
    int
gui_mch_init_font(char_u *font_name, int fontset)
{
    vimjs_init_font((char*)font_name);

    gui.char_width = vimjs_get_char_width();
    gui.char_height = vimjs_get_char_height();
    gui.char_ascent = gui.char_height;

    char_u buf[100];

    gui.norm_font = vim_strsave(font_name);
        
    vim_strncpy(buf, "bold ", 99); // should report 1 less to vim_strncpy 
    vim_strcat(buf, font_name, 100);
    gui.bold_font = vim_strsave(buf);

    vim_strncpy(buf, "italic ", 99); // should report 1 less to vim_strncpy 
    vim_strcat(buf, font_name, 100);
    gui.ital_font = vim_strsave(buf);

    vim_strncpy(buf, "bold italic ", 99); // should report 1 less to vim_strncpy 
    vim_strcat(buf, font_name, 100);
    gui.boldital_font = vim_strsave(buf);

    int w,h;
    w = vimjs_get_window_width();
    h = vimjs_get_window_height();
    gui_resize_shell(w, h);

    return OK;
}
示例#2
0
/*
 * Recalculate Rows and Columns
 * Keep the text area fully occupied
 */
    static void
gui_browser_resize(void)
{
    int w, h;
    gui_mch_get_screen_dimensions(&w, &h);
    gui_resize_shell(w, h);
}
示例#3
0
/**
 * Resize the shell
 */
void
gui_mch_set_shellsize(int width, int height, int min_width, int min_height,
		    int base_width, int base_height, int direction)
{
	//
	// We don't actually resize the shell here, instead we
	// call Qt to do it for us.
	//
	gui_resize_shell(vimshell->size().width(), vimshell->size().height());
}
示例#4
0
/**
 * Resize the shell
 */
void
gui_mch_set_shellsize(int width, int height, int min_width, int min_height,
		    int base_width, int base_height, int direction)
{
	// We actually resize the window, not the shell, i.e. we resize the window
	// to the new dimensions plus the difference between the window and the shell.
	// This does not ensure the final size is what Vim requested.
	//
	// The actual resize size must take into consideration
	// - The new shell widget size
	// - The toolbar/menubar/etc size
	//
	// New size <= shell size - window size + new size
	//

	QDesktopWidget *dw = QApplication::desktop();
	QSize desktopSize = dw->availableGeometry(window).size();

	if ( !window->isVisible() ) {
		// We can't resize properly if the window is not
		// visible just resize the window to the intended size
		if ( width > desktopSize.width() ) {
			width = desktopSize.width();
		}
		if ( height > desktopSize.height() ) {
			height = desktopSize.height();
		}

		window->resize(width, height);
		return;
	}

	int decoWidth = (window->frameGeometry().width() - window->width());
	int decoHeight = (window->frameGeometry().height() - window->height());
	int frameWidth = (window->size().width() - vimshell->size().width());
	int frameHeight = (window->size().height() - vimshell->size().height());

	int new_width = frameWidth + width;
	int new_height = frameHeight + height;

	// If the given dimenstions are too large,
	// cap them at available desktop dimensions minus the window decorations
	if ( new_width + decoWidth > desktopSize.width() ) {
		new_width = desktopSize.width() - decoWidth;
	}
	if ( new_height + decoWidth > desktopSize.height() ) {
		new_height = desktopSize.height() - decoHeight;
	}

	if (window->windowState() & Qt::WindowFullScreen ) {
		// In fullscreen mode, resize the widget
		vimshell->setMaximumSize(width, height);
	} else if ( window->isMaximized() ) {
		// Nothing to do here - the windows is maximized
	} else {
		window->resize( new_width, new_height );
	}

	//
	// Spin the loop to handle the resize event. This will
	// cause gui_resize_shell() to be called
	gui_mch_update();

	// Seems redundant but there are cases were the shell might not
	// call this - because its size is unchanged
	gui_resize_shell(vimshell->width(), vimshell->height());

	// SHOCKING: it seems gui_get_shellsize() updates the proper values for
	// the columns and rows, after a resize.
	gui_get_shellsize();
}