console_t *uimon_window_open(void) { GtkWidget *scrollbar, *horizontal_container; if (fixed.window == NULL) { fixed.window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(fixed.window), "VICE monitor"); gtk_window_set_position(GTK_WINDOW(fixed.window), GTK_WIN_POS_CENTER); gtk_widget_set_app_paintable(fixed.window, TRUE); gtk_window_set_deletable(GTK_WINDOW(fixed.window), TRUE); fixed.term = vte_terminal_new(); vte_terminal_set_scrollback_lines (VTE_TERMINAL(fixed.term), 1000); vte_terminal_set_scroll_on_output (VTE_TERMINAL(fixed.term), TRUE); scrollbar = gtk_vscrollbar_new(vte_terminal_get_adjustment (VTE_TERMINAL(fixed.term))); horizontal_container = gtk_hbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(fixed.window), horizontal_container); gtk_container_add(GTK_CONTAINER(horizontal_container), fixed.term); gtk_container_add(GTK_CONTAINER(horizontal_container), scrollbar); g_signal_connect(G_OBJECT(fixed.window), "delete-event", G_CALLBACK(close_window), &fixed.input_buffer); g_signal_connect(G_OBJECT(fixed.term), "key-press-event", G_CALLBACK(key_press_event), &fixed.input_buffer); g_signal_connect(G_OBJECT(fixed.term), "button-press-event", G_CALLBACK(button_press_event), &fixed.input_buffer); vte_console.console_xres = vte_terminal_get_column_count(VTE_TERMINAL(fixed.term)); vte_console.console_yres = vte_terminal_get_row_count(VTE_TERMINAL(fixed.term)); vte_console.console_can_stay_open = 1; } return uimon_window_resume(); }
GtkWidget *terminal_create (GError **error) { GtkWidget *self = vte_terminal_new(); VtePty *self_pty = vte_pty_new(0, error); if (!self_pty){ g_free(self); return NULL; } else { GPid c_pid = 0; char *c_argv[] = { "dmesg", NULL }; vte_terminal_set_pty_object(VTE_TERMINAL(self), self_pty); c_argv[0] = getenv("SHELL"); if(g_spawn_async(getenv("HOME"), c_argv, NULL, G_SPAWN_DO_NOT_REAP_CHILD, (GSpawnChildSetupFunc) vte_pty_child_setup, (void *) self_pty, &c_pid, error)){ g_child_watch_add(c_pid, terminal_child_exited, self); } else { vte_pty_close(self_pty); g_object_unref(self_pty); g_object_unref(self); return NULL; } } vte_terminal_set_opacity(VTE_TERMINAL(self), 0); vte_terminal_set_scrollback_lines(VTE_TERMINAL(self), 255); return self; }
static void mud_subwindow_set_terminal_scrollback(MudSubwindow *self) { g_return_if_fail(MUD_IS_SUBWINDOW(self)); vte_terminal_set_scrollback_lines(VTE_TERMINAL(self->priv->terminal), self->priv->parent_view->profile->preferences->Scrollback); }
Terminal::Terminal() { dock_hint = GdkRectangle{0, 0, 0, 0}; vte = vte_terminal_new(); char *argv[] = { vte_get_user_shell(), NULL }; vte_terminal_spawn_sync(VTE_TERMINAL(vte), VTE_PTY_DEFAULT, NULL, argv, NULL, (GSpawnFlags)0, NULL, NULL, &child_pid, NULL, NULL); set_orientation(Gtk::ORIENTATION_VERTICAL); scrollbox.set_orientation(Gtk::ORIENTATION_HORIZONTAL); scrollbar.set_orientation(Gtk::ORIENTATION_VERTICAL); eventbox.add(label); eventbox.signal_button_press_event().connect(mem_fun(this, &Terminal::header_button_press)); VteRegex *regex = vte_regex_new_for_match("(https?://|www\\.)[^\\s]*", -1, PCRE2_MULTILINE, NULL); vte_terminal_match_add_regex(VTE_TERMINAL(vte), regex, 0); vte_terminal_set_scrollback_lines(VTE_TERMINAL(vte), 10000); g_signal_connect(vte, "bell", G_CALLBACK(Terminal::vte_beep), this); g_signal_connect(vte, "child-exited", G_CALLBACK(Terminal::vte_child_exited), this); g_signal_connect(vte, "button-press-event", G_CALLBACK(Terminal::vte_click), this); g_signal_connect(vte, "focus-in-event", G_CALLBACK(Terminal::vte_got_focus), this); g_signal_connect(vte, "focus-out-event", G_CALLBACK(Terminal::vte_lost_focus), this); g_signal_connect(vte, "selection-changed", G_CALLBACK(Terminal::vte_selection_changed), this); g_signal_connect(vte, "window-title-changed", G_CALLBACK(Terminal::vte_title_changed), this); searchbar.add(searchentry); searchbar.connect_entry(searchentry); searchentry.signal_focus_out_event().connect(mem_fun(this, &Terminal::searchentry_lost_focus)); searchentry.signal_key_release_event().connect(mem_fun(this, &Terminal::searchentry_keypress)); pack_start(eventbox, false, false, 0); pack_start(scrollbox, true, true, 0); pack_start(searchbar, false, false, 0); gtk_box_pack_start(GTK_BOX(scrollbox.gobj()), vte, true, true, 0); scrollbox.pack_start(scrollbar, false, false, 0); gtk_range_set_adjustment(GTK_RANGE(scrollbar.gobj()), gtk_scrollable_get_vadjustment(GTK_SCROLLABLE(vte))); show_all_children(); find_label.terminal = this; find_label.set_alignment(0.0, 0.5); find_window->list_box.prepend(find_label); std::vector<Gtk::TargetEntry> listTargets; listTargets.push_back(Gtk::TargetEntry("SvanTerminal", Gtk::TARGET_SAME_APP, 0)); eventbox.drag_source_set(listTargets); drag_dest_set(listTargets); eventbox.signal_drag_begin().connect(sigc::mem_fun(this, &Terminal::on_my_drag_begin)); eventbox.signal_drag_failed().connect(sigc::mem_fun(this, &Terminal::on_my_drag_failed)); eventbox.signal_drag_end().connect(sigc::mem_fun(this, &Terminal::on_my_drag_end)); signal_drag_motion().connect(sigc::mem_fun(this, &Terminal::on_my_drag_motion)); signal_drag_drop().connect(sigc::mem_fun(this, &Terminal::on_my_drag_drop)); signal_drag_leave().connect(sigc::mem_fun(this, &Terminal::on_my_drag_leave)); }
GtkWidget* build_term(void) { if(!popupmenu) build_popupmenu(); GtkWidget* term = vte_terminal_new(); term_fork_command(VTE_TERMINAL(term), conf_get_shell()); if (conf_get_bg_image() != NULL) vte_terminal_set_background_image_file(VTE_TERMINAL(term), conf_get_bg_image()); GdkColor fore, back; fore = conf_get_fg(); back = conf_get_bg(); GdkColor *palette = conf_get_color_palette(); if(palette == NULL) vte_terminal_set_colors(VTE_TERMINAL(term), &fore, &back, NULL, 0); else vte_terminal_set_colors(VTE_TERMINAL(term), &fore, &back, palette, 16); #if VTE_CHECK_VERSION(0,25,0) vte_pty_set_term(vte_terminal_get_pty_object(VTE_TERMINAL(term)), conf_get_emulation()); #endif vte_terminal_set_background_tint_color(VTE_TERMINAL(term), &back); vte_terminal_set_allow_bold(VTE_TERMINAL(term), conf_get_allow_bold()); vte_terminal_set_scroll_on_output(VTE_TERMINAL(term), conf_get_scroll_on_output()); vte_terminal_set_scroll_on_keystroke(VTE_TERMINAL(term), TRUE); vte_terminal_set_font_from_string(VTE_TERMINAL(term), conf_get_font()); vte_terminal_set_scrollback_lines(VTE_TERMINAL(term), conf_get_lines()); vte_terminal_set_backspace_binding(VTE_TERMINAL(term), VTE_ERASE_ASCII_DELETE); vte_terminal_set_word_chars(VTE_TERMINAL(term), "-A-Za-z0-9_$.+!*(),;:@&=?/~#%"); GdkColor cursor = conf_get_cursor_color(); vte_terminal_set_cursor_blink_mode(VTE_TERMINAL(term), conf_get_cursor_blink() ? VTE_CURSOR_BLINK_ON : VTE_CURSOR_BLINK_OFF); vte_terminal_set_cursor_shape(VTE_TERMINAL(term), conf_get_cursor_shape()); vte_terminal_set_color_cursor(VTE_TERMINAL(term), &cursor); term_connect_signals(term); return term; }
void on_vte_realize(VteTerminal *vte, G_GNUC_UNUSED gpointer gdata) { vte_terminal_set_emulation(vte, pref_vte_emulation); vte_terminal_set_font_from_string(vte, pref_vte_font); vte_terminal_set_scrollback_lines(vte, pref_vte_scrollback); vte_terminal_set_scroll_on_output(vte, TRUE); vte_terminal_set_color_foreground(vte, &pref_vte_colour_fore); vte_terminal_set_color_background(vte, &pref_vte_colour_back); #if VTE_CHECK_VERSION(0, 17, 1) vte_terminal_set_cursor_blink_mode(vte, pref_vte_blinken ? VTE_CURSOR_BLINK_ON : VTE_CURSOR_BLINK_OFF); #else vte_terminal_set_cursor_blinks(vte, pref_vte_blinken); #endif }
GtkWidget* create_horst_window(void) { GtkWidget *horst_window, *horst_term; char *envs[2]; char *params[] = {horstpath}; envs[0] = strdup(environments); envs[1] = NULL; VtePtyFlags pty_flags = 0; GSpawnFlags spawn_flags = 0; char horst_title[24]; params[0] = strdup(horstpath); params[1] = strdup("-c"); params[2] = strdup("192.168.1.125"); params[3] = NULL; /* params[0] = strdup(horstpath); params[1] = strdup("-i"); params[2] = strdup(wificards[chan_detail]); params[3] = NULL; */ horst_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); sprintf(horst_title, "channel %d signal details", horst_chans[chan_detail]); gtk_window_set_title (GTK_WINDOW(horst_window), strdup(horst_title)); gtk_container_set_border_width(GTK_CONTAINER(horst_window), 0); horst_term = vte_terminal_new(); gtk_container_add(GTK_CONTAINER(horst_window), horst_term); vte_terminal_set_size(VTE_TERMINAL(horst_term), 100, 50); gtk_widget_show(horst_term); gtk_widget_set_visible (GTK_WIDGET(horst_term), TRUE); vte_terminal_fork_command_full (VTE_TERMINAL(horst_term), pty_flags, kislogdir , params, envs, spawn_flags, NULL, NULL, NULL, NULL); vte_terminal_set_scrollback_lines(VTE_TERMINAL(horst_term), 1024); gtk_widget_grab_focus(horst_term); g_signal_connect(G_OBJECT(horst_window), "destroy", G_CALLBACK(horst_delete), horst_window); return horst_window; }
static void vte_config(VteTerminal* vte) { GRegex* regex = g_regex_new(url_regex, G_REGEX_CASELESS, G_REGEX_MATCH_NOTEMPTY, NULL); vte_terminal_search_set_gregex(vte, regex, G_REGEX_MATCH_NOTEMPTY); vte_terminal_search_set_wrap_around (vte, TINYTERM_SEARCH_WRAP_AROUND); vte_terminal_set_audible_bell (vte, TINYTERM_AUDIBLE_BELL); vte_terminal_set_cursor_shape (vte, TINYTERM_CURSOR_SHAPE); vte_terminal_set_cursor_blink_mode (vte, TINYTERM_CURSOR_BLINK); vte_terminal_set_word_char_exceptions (vte, TINYTERM_WORD_CHARS); vte_terminal_set_scrollback_lines (vte, TINYTERM_SCROLLBACK_LINES); PangoFontDescription *font = pango_font_description_from_string(TINYTERM_FONT); vte_terminal_set_font(vte, font); GdkRGBA color_fg, color_bg; GdkRGBA color_palette[16]; gdk_rgba_parse(&color_fg, TINYTERM_COLOR_FOREGROUND); gdk_rgba_parse(&color_bg, TINYTERM_COLOR_BACKGROUND); gdk_rgba_parse(&color_palette[0], TINYTERM_COLOR00); gdk_rgba_parse(&color_palette[1], TINYTERM_COLOR01); gdk_rgba_parse(&color_palette[2], TINYTERM_COLOR02); gdk_rgba_parse(&color_palette[3], TINYTERM_COLOR03); gdk_rgba_parse(&color_palette[4], TINYTERM_COLOR04); gdk_rgba_parse(&color_palette[5], TINYTERM_COLOR05); gdk_rgba_parse(&color_palette[6], TINYTERM_COLOR06); gdk_rgba_parse(&color_palette[7], TINYTERM_COLOR07); gdk_rgba_parse(&color_palette[8], TINYTERM_COLOR08); gdk_rgba_parse(&color_palette[9], TINYTERM_COLOR09); gdk_rgba_parse(&color_palette[10], TINYTERM_COLOR0A); gdk_rgba_parse(&color_palette[11], TINYTERM_COLOR0B); gdk_rgba_parse(&color_palette[12], TINYTERM_COLOR0C); gdk_rgba_parse(&color_palette[13], TINYTERM_COLOR0D); gdk_rgba_parse(&color_palette[14], TINYTERM_COLOR0E); gdk_rgba_parse(&color_palette[15], TINYTERM_COLOR0F); vte_terminal_set_colors(vte, &color_fg, &color_bg, &color_palette, 16); }
GtkWidget* build_term(void) { if (!popupmenu) build_popupmenu(); GtkWidget* term = vte_terminal_new(); vte_terminal_fork_command(VTE_TERMINAL(term), conf_get_shell(), NULL, NULL, "", TRUE, TRUE, TRUE); if (conf_get_bg_image() != NULL) vte_terminal_set_background_image_file(VTE_TERMINAL(term), conf_get_bg_image()); GdkColor fore, back; fore = conf_get_fg(); back = conf_get_bg(); GdkColor *palette = conf_get_color_palette(); if (palette == NULL) vte_terminal_set_colors(VTE_TERMINAL(term), &fore, &back, NULL, 0); else vte_terminal_set_colors(VTE_TERMINAL(term), &fore, &back, palette, 16); vte_terminal_set_background_tint_color(VTE_TERMINAL(term), &back); vte_terminal_set_allow_bold(VTE_TERMINAL(term), conf_get_allow_bold()); vte_terminal_set_scroll_on_output(VTE_TERMINAL(term), conf_get_scroll_on_output()); vte_terminal_set_scroll_on_keystroke(VTE_TERMINAL(term), TRUE); vte_terminal_set_font_from_string(VTE_TERMINAL(term), conf_get_font()); vte_terminal_set_scrollback_lines(VTE_TERMINAL(term), conf_get_lines()); vte_terminal_set_backspace_binding(VTE_TERMINAL(term), VTE_ERASE_ASCII_DELETE); vte_terminal_set_audible_bell (VTE_TERMINAL(term), conf_get_bell()); vte_terminal_set_cursor_blink_mode(VTE_TERMINAL(term), conf_get_cursor_blink()); vte_terminal_set_cursor_shape(VTE_TERMINAL(term), conf_get_cursor_shape()); term_connect_signals(term); return term; }
void terminal::setup_terminal() { if ( m_terminal && m_configuration ) { GError *error = NULL; vte_terminal_set_scrollback_lines(m_terminal, m_configuration->get_scrollback_lines()); vte_terminal_set_allow_bold(m_terminal, m_configuration->get_allow_bold()); vte_terminal_set_audible_bell(m_terminal, m_configuration->get_audible_bell()); vte_terminal_set_scroll_on_keystroke(m_terminal, m_configuration->get_scroll_on_keystroke()); vte_terminal_set_scroll_on_output(m_terminal, m_configuration->get_scroll_on_output()); vte_terminal_set_rewrap_on_resize(m_terminal, m_configuration->get_rewrap_on_resize()); vte_terminal_set_mouse_autohide(m_terminal, m_configuration->get_autohide_mouse()); if ( ! vte_terminal_set_encoding(m_terminal, m_configuration->get_encoding().c_str(), &error) ) { sterm::common::warning("sterm::terminal", "failed to set terminal encoding to '%s'", m_configuration->get_encoding().c_str()); sterm::common::debug("sterm::terminal", "VteTerminal error message: %s", error->message); } std::string word_chars = m_configuration->get_word_chars(); if ( ! word_chars.empty() ) vte_terminal_set_word_char_exceptions(m_terminal, word_chars.c_str()); else vte_terminal_set_word_char_exceptions(m_terminal, NULL); vte_terminal_set_cursor_blink_mode(m_terminal, m_configuration->get_cursor_blink_mode()); vte_terminal_set_cursor_shape(m_terminal, m_configuration->get_cursor_shape()); PangoFontDescription *font = NULL; if ( m_configuration->copy_font_description(&font) ) { vte_terminal_set_font(m_terminal, font); pango_font_description_free(font); } else { vte_terminal_set_font(m_terminal, NULL); } std::vector<GdkRGBA> color_palette = m_configuration->get_color_palette(); color foreground = m_configuration->get_foreground_color(); color background = m_configuration->get_background_color(); color bold_color = m_configuration->get_bold_color(); color cursor_color = m_configuration->get_cursor_color(); color highlight_bg = m_configuration->get_highlight_bg_color(); color highlight_fg = m_configuration->get_highlight_fg_color(); if ( color_palette.size() == PALETTE_SIZE ) vte_terminal_set_colors(m_terminal, NULL, NULL, color_palette.data(), PALETTE_SIZE); else vte_terminal_set_default_colors(m_terminal); if ( foreground.set ) vte_terminal_set_color_foreground(m_terminal, &(foreground.value)); if ( background.set ) vte_terminal_set_color_background(m_terminal, &(background.value)); if ( bold_color.set ) vte_terminal_set_color_bold(m_terminal, &(bold_color.value)); else vte_terminal_set_color_bold(m_terminal, NULL); if ( cursor_color.set ) vte_terminal_set_color_cursor(m_terminal, &(cursor_color.value)); else vte_terminal_set_color_cursor(m_terminal, NULL); if ( highlight_bg.set ) vte_terminal_set_color_highlight(m_terminal, &(highlight_bg.value)); else vte_terminal_set_color_highlight(m_terminal, NULL); if ( highlight_fg.set ) vte_terminal_set_color_highlight_foreground(m_terminal, &(highlight_fg.value)); else vte_terminal_set_color_highlight_foreground(m_terminal, NULL); } }
/* create a new tab */ static void tab_new(struct window *w) { term *t; int tmp; char **args = 0; const gchar *shell = g_getenv("SHELL"); if (!shell) { shell = "sh"; } g_shell_parse_argv(shell, 0, &args, 0); t = g_new0(term, 1); t->label = gtk_label_new(""); t->w = w; t->vte = vte_terminal_new(); int index = gtk_notebook_append_page(GTK_NOTEBOOK(w->notebook), t->vte, t->label); gtk_notebook_set_tab_reorderable(GTK_NOTEBOOK(w->notebook), t->vte, TRUE); if (index == 0) { gtk_notebook_set_show_tabs(GTK_NOTEBOOK(w->notebook), FALSE); vte_terminal_fork_command_full(VTE_TERMINAL(t->vte), VTE_PTY_DEFAULT, NULL, args, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, t->pid, NULL); tab_geometry_hints(t); } else { struct term *previous = get_nth_term(w, gtk_notebook_get_current_page(GTK_NOTEBOOK(w->notebook))); vte_terminal_fork_command_full(VTE_TERMINAL(t->vte), VTE_PTY_DEFAULT, tab_get_cwd(previous), args, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, t->pid, NULL); gtk_notebook_set_show_tabs(GTK_NOTEBOOK(w->notebook), TRUE); } g_object_set_qdata_full(G_OBJECT(gtk_notebook_get_nth_page( (GtkNotebook*)w->notebook, index)), term_data_id, t, NULL); g_signal_connect(G_OBJECT(t->vte), "child-exited", G_CALLBACK(tab_close), w); g_signal_connect(G_OBJECT(t->vte), "window-title-changed", G_CALLBACK(tab_title), t); g_signal_connect(G_OBJECT(t->vte), "button-press-event", G_CALLBACK(event_button), NULL); vte_terminal_set_allow_bold(VTE_TERMINAL(t->vte), config->allow_bold); vte_terminal_set_audible_bell(VTE_TERMINAL(t->vte), config->audible_bell); vte_terminal_set_background_transparent(VTE_TERMINAL(t->vte), config->bg_transparent); vte_terminal_set_background_saturation(VTE_TERMINAL(t->vte), config->bg_saturation); vte_terminal_set_background_image_file(VTE_TERMINAL(t->vte), config->bg_image); vte_terminal_set_font_from_string(VTE_TERMINAL(t->vte), config->font); vte_terminal_set_mouse_autohide(VTE_TERMINAL(t->vte), config->autohide_mouse); vte_terminal_set_scroll_on_keystroke(VTE_TERMINAL(t->vte), config->scroll_on_keystroke); vte_terminal_set_scroll_on_output(VTE_TERMINAL(t->vte), config->scroll_on_output); vte_terminal_set_scrollback_lines(VTE_TERMINAL(t->vte), config->num_scrollback_lines); vte_terminal_set_visible_bell(VTE_TERMINAL(t->vte), config->visible_bell); vte_terminal_set_word_chars(VTE_TERMINAL(t->vte), config->word_chars); vte_terminal_set_colors(VTE_TERMINAL(t->vte), &config->foreground, &config->background, config->colour_palette, DEFAULT_PALETTE_SIZE); tmp = vte_terminal_match_add_gregex( VTE_TERMINAL(t->vte), g_regex_new(config->url_regex, G_REGEX_CASELESS, G_REGEX_MATCH_NOTEMPTY, NULL), 0); vte_terminal_match_set_cursor_type(VTE_TERMINAL(t->vte), tmp, GDK_HAND2); gtk_widget_show_all(w->notebook); gtk_notebook_set_current_page(GTK_NOTEBOOK(w->notebook), index); gtk_widget_grab_focus(t->vte); }
static void configure_term_widget (VteTerminal *vtterm, GVariantDict *options) { /* Pick default settings from the settings... */ dg_lmem gchar *opt_font = NULL; dg_lmem gchar *opt_theme = NULL; dg_lmem gchar *opt_fgcolor = NULL; dg_lmem gchar *opt_bgcolor = NULL; gboolean opt_bold; guint opt_scroll; DwtSettings *settings = dwt_settings_get_instance (); g_object_get (settings, "font", &opt_font, "theme", &opt_theme, "allow-bold", &opt_bold, "scrollback", &opt_scroll, "foreground-color", &opt_fgcolor, "background-color", &opt_bgcolor, NULL); /* * This ensures that properties are updated for the terminal whenever they * change in the configuration files. * * TODO: For now this is done only for those properties which cannot be * overriden using command line flags. */ static const struct { const gchar *setting_name; const gchar *property_name; GBindingFlags bind_flags; } property_bind_map[] = { { "mouse-autohide", "pointer-autohide", G_BINDING_SYNC_CREATE }, { "audible-bell", "audible-bell", G_BINDING_SYNC_CREATE }, }; for (guint i = 0; i < G_N_ELEMENTS (property_bind_map); i++) { g_object_bind_property (settings, property_bind_map[i].setting_name, G_OBJECT (vtterm), property_bind_map[i].property_name, property_bind_map[i].bind_flags); } /* ...and allow command line options to override them. */ if (options) { dg_lmem gchar *cmd_font = NULL; g_variant_dict_lookup (options, "font", "s", &cmd_font); if (cmd_font) SWAP (gchar*, cmd_font, opt_font); dg_lmem gchar *cmd_theme = NULL; g_variant_dict_lookup (options, "theme", "s", &cmd_theme); if (cmd_theme) SWAP (gchar*, cmd_theme, opt_theme); g_variant_dict_lookup (options, "allow-bold", "b", &opt_bold); g_variant_dict_lookup (options, "scrollback", "u", &opt_scroll); } PangoFontDescription *fontd = pango_font_description_from_string (opt_font); if (fontd) { if (!pango_font_description_get_family (fontd)) pango_font_description_set_family_static (fontd, "monospace"); if (!pango_font_description_get_size (fontd)) pango_font_description_set_size (fontd, 12 * PANGO_SCALE); vte_terminal_set_font (vtterm, fontd); pango_font_description_free (fontd); fontd = NULL; } const Theme *theme = &themes[1]; if (opt_theme) { theme = find_theme (opt_theme); if (!theme) { g_printerr ("No such theme '%s', using default (linux)\n", opt_theme); theme = &themes[1]; } } GdkRGBA fgcolor, bgcolor; if (!(opt_fgcolor && gdk_rgba_parse (&fgcolor, opt_fgcolor))) fgcolor = theme->fg; if (!(opt_bgcolor && gdk_rgba_parse (&bgcolor, opt_bgcolor))) bgcolor = theme->bg; vte_terminal_set_rewrap_on_resize (vtterm, TRUE); vte_terminal_set_scroll_on_keystroke (vtterm, TRUE); vte_terminal_set_audible_bell (vtterm, FALSE); vte_terminal_set_scroll_on_output (vtterm, FALSE); vte_terminal_set_allow_bold (vtterm, opt_bold); vte_terminal_set_scrollback_lines (vtterm, opt_scroll); vte_terminal_set_cursor_blink_mode (vtterm, VTE_CURSOR_BLINK_OFF); vte_terminal_set_cursor_shape (vtterm, VTE_CURSOR_SHAPE_BLOCK); vte_terminal_set_colors (vtterm, &fgcolor, &bgcolor, theme->colors, G_N_ELEMENTS (theme->colors)); const GRegexCompileFlags regex_compile_flags = G_REGEX_CASELESS | G_REGEX_OPTIMIZE | G_REGEX_MULTILINE; gint match_tag = vte_terminal_match_add_gregex (vtterm, g_regex_new (uri_regexp, regex_compile_flags, G_REGEX_MATCH_NOTEMPTY, NULL), G_REGEX_MATCH_NOTEMPTY); vte_terminal_match_set_cursor_type (vtterm, match_tag, GDK_HAND2); }
/* * Class: com_randomwalking_swt_terminal_internal_Vte * Method: _vte_terminal_set_scrollback_lines * Signature: (II)V */ JNIEXPORT void JNICALL Java_com_randomwalking_swt_terminal_internal_Vte__1vte_1terminal_1set_1scrollback_1lines (JNIEnv * env, jclass obj, jint terminal, jint lines) { vte_terminal_set_scrollback_lines(VTE_TERMINAL(terminal), lines); }
static VALUE rg_set_scrollback_lines(VALUE self, VALUE lines) { vte_terminal_set_scrollback_lines(_SELF(self), NUM2LONG(lines)); return self; }
gboolean setup_term(GtkWidget *win, GtkWidget *term, struct term_options *to) { static char *args_default[] = { NULL, NULL, NULL }; char **args_use; size_t i; GdkRGBA c_foreground_gdk; GdkRGBA c_background_gdk; GdkRGBA c_palette_gdk[16]; GdkRGBA c_gdk; VteRegex *url_vregex = NULL; GError *err = NULL; GSpawnFlags spawn_flags; if (to->argv != NULL) { args_use = to->argv; spawn_flags = G_SPAWN_SEARCH_PATH; } else { if (args_default[0] == NULL) { args_default[0] = vte_get_user_shell(); if (args_default[0] == NULL) args_default[0] = "/bin/sh"; if (login_shell) args_default[1] = g_strdup_printf("-%s", args_default[0]); else args_default[1] = args_default[0]; } args_use = args_default; spawn_flags = G_SPAWN_SEARCH_PATH | G_SPAWN_FILE_AND_ARGV_ZERO; } /* Appearance. */ term_set_font(NULL, VTE_TERMINAL(term), 0); gtk_widget_show_all(win); vte_terminal_set_allow_bold(VTE_TERMINAL(term), enable_bold); vte_terminal_set_cursor_blink_mode(VTE_TERMINAL(term), VTE_CURSOR_BLINK_OFF); vte_terminal_set_geometry_hints_for_window(VTE_TERMINAL(term), GTK_WINDOW(win)); vte_terminal_set_mouse_autohide(VTE_TERMINAL(term), TRUE); vte_terminal_set_scrollback_lines(VTE_TERMINAL(term), scrollback_lines); gdk_rgba_parse(&c_foreground_gdk, c_foreground); gdk_rgba_parse(&c_background_gdk, c_background); for (i = 0; i < 16; i++) gdk_rgba_parse(&c_palette_gdk[i], c_palette[i]); vte_terminal_set_colors(VTE_TERMINAL(term), &c_foreground_gdk, &c_background_gdk, c_palette_gdk, 16); if (c_bold != NULL) { gdk_rgba_parse(&c_gdk, c_bold); vte_terminal_set_color_bold(VTE_TERMINAL(term), &c_gdk); } if (c_cursor != NULL) { gdk_rgba_parse(&c_gdk, c_cursor); vte_terminal_set_color_cursor(VTE_TERMINAL(term), &c_gdk); } if (c_cursor_foreground != NULL) { gdk_rgba_parse(&c_gdk, c_cursor_foreground); vte_terminal_set_color_cursor_foreground(VTE_TERMINAL(term), &c_gdk); } url_vregex = vte_regex_new_for_match(url_regex, strlen(url_regex), PCRE2_MULTILINE | PCRE2_CASELESS, &err); if (url_vregex == NULL) fprintf(stderr, "url_regex: %s\n", err == NULL ? "<err is NULL>" : err->message); else { vte_terminal_match_add_regex(VTE_TERMINAL(term), url_vregex, 0); vte_regex_unref(url_vregex); } /* Signals. */ g_signal_connect(G_OBJECT(term), "bell", G_CALLBACK(sig_bell), win); g_signal_connect(G_OBJECT(term), "button-press-event", G_CALLBACK(sig_button_press), NULL); if (!to->hold) g_signal_connect(G_OBJECT(term), "child-exited", G_CALLBACK(sig_child_exited), win); g_signal_connect(G_OBJECT(term), "decrease-font-size", G_CALLBACK(sig_decrease_font_size), win); g_signal_connect(G_OBJECT(term), "increase-font-size", G_CALLBACK(sig_increase_font_size), win); g_signal_connect(G_OBJECT(term), "key-press-event", G_CALLBACK(sig_key_press), win); g_signal_connect(G_OBJECT(term), "resize-window", G_CALLBACK(sig_window_resize), win); g_signal_connect(G_OBJECT(term), "window-title-changed", G_CALLBACK(sig_window_title_changed), win); /* Spawn child. */ return vte_terminal_spawn_sync(VTE_TERMINAL(term), VTE_PTY_DEFAULT, to->cwd, args_use, NULL, spawn_flags, NULL, NULL, NULL, NULL, NULL); }
/** * tilda_term_config_defaults () * * Read and set all of the defaults for this terminal from the current configuration. * * Success: return 0 * Failure: return non-zero */ static gint tilda_term_config_defaults (tilda_term *tt) { DEBUG_FUNCTION ("tilda_term_config_defaults"); DEBUG_ASSERT (tt != NULL); gdouble transparency_level = 0.0; GdkRGBA fg, bg, cc; gchar* word_chars; gint i; gint cursor_shape; /** Colors & Palette **/ bg.red = GUINT16_TO_FLOAT(config_getint ("back_red")); bg.green = GUINT16_TO_FLOAT(config_getint ("back_green")); bg.blue = GUINT16_TO_FLOAT(config_getint ("back_blue")); bg.alpha = 1.0; fg.red = GUINT16_TO_FLOAT(config_getint ("text_red")); fg.green = GUINT16_TO_FLOAT(config_getint ("text_green")); fg.blue = GUINT16_TO_FLOAT(config_getint ("text_blue")); fg.alpha = 1.0; cc.red = GUINT16_TO_FLOAT(config_getint ("cursor_red")); cc.green = GUINT16_TO_FLOAT(config_getint ("cursor_green")); cc.blue = GUINT16_TO_FLOAT(config_getint ("cursor_blue")); cc.alpha = 1.0; for(i = 0;i < TERMINAL_PALETTE_SIZE; i++) { current_palette[i].red = GUINT16_TO_FLOAT(config_getnint ("palette", i*3)); current_palette[i].green = GUINT16_TO_FLOAT(config_getnint ("palette", i*3+1)); current_palette[i].blue = GUINT16_TO_FLOAT(config_getnint ("palette", i*3+2)); current_palette[i].alpha = 1.0; } vte_terminal_set_colors_rgba (VTE_TERMINAL(tt->vte_term), &fg, &bg, current_palette, TERMINAL_PALETTE_SIZE); /** Bells **/ vte_terminal_set_audible_bell (VTE_TERMINAL(tt->vte_term), config_getbool ("bell")); vte_terminal_set_visible_bell (VTE_TERMINAL(tt->vte_term), config_getbool ("bell")); /** Cursor **/ vte_terminal_set_cursor_blink_mode (VTE_TERMINAL(tt->vte_term), (config_getbool ("blinks"))?VTE_CURSOR_BLINK_ON:VTE_CURSOR_BLINK_OFF); vte_terminal_set_color_cursor_rgba (VTE_TERMINAL(tt->vte_term), &cc); cursor_shape = config_getint("cursor_shape"); if (cursor_shape < 0 || cursor_shape > 2) { config_setint("cursor_shape", 0); cursor_shape = 0; } vte_terminal_set_cursor_shape(VTE_TERMINAL(tt->vte_term), (VteTerminalCursorShape)cursor_shape); /** Scrolling **/ vte_terminal_set_scroll_background (VTE_TERMINAL(tt->vte_term), config_getbool ("scroll_background")); vte_terminal_set_scroll_on_output (VTE_TERMINAL(tt->vte_term), config_getbool ("scroll_on_output")); vte_terminal_set_scroll_on_keystroke (VTE_TERMINAL(tt->vte_term), config_getbool ("scroll_on_key")); /** Mouse **/ vte_terminal_set_mouse_autohide (VTE_TERMINAL(tt->vte_term), FALSE); /* TODO: make this configurable */ /** Text Properties **/ vte_terminal_set_allow_bold (VTE_TERMINAL(tt->vte_term), config_getbool ("bold")); gtk_widget_set_double_buffered (tt->vte_term, config_getbool("double_buffer")); PangoFontDescription *description = pango_font_description_from_string (config_getstr ("font")); vte_terminal_set_font (VTE_TERMINAL (tt->vte_term), description); /** Scrollback **/ vte_terminal_set_scrollback_lines (VTE_TERMINAL(tt->vte_term), config_getbool("scroll_history_infinite") ? -1 : config_getint ("lines")); /** Keys **/ switch (config_getint ("backspace_key")) { case ASCII_DELETE: vte_terminal_set_backspace_binding (VTE_TERMINAL(tt->vte_term), VTE_ERASE_ASCII_DELETE); break; case DELETE_SEQUENCE: vte_terminal_set_backspace_binding (VTE_TERMINAL(tt->vte_term), VTE_ERASE_DELETE_SEQUENCE); break; case ASCII_BACKSPACE: vte_terminal_set_backspace_binding (VTE_TERMINAL(tt->vte_term), VTE_ERASE_ASCII_BACKSPACE); break; case AUTO: default: vte_terminal_set_backspace_binding (VTE_TERMINAL(tt->vte_term), VTE_ERASE_AUTO); break; } switch (config_getint ("delete_key")) { case ASCII_DELETE: vte_terminal_set_delete_binding (VTE_TERMINAL(tt->vte_term), VTE_ERASE_ASCII_DELETE); break; case DELETE_SEQUENCE: vte_terminal_set_delete_binding (VTE_TERMINAL(tt->vte_term), VTE_ERASE_DELETE_SEQUENCE); break; case ASCII_BACKSPACE: vte_terminal_set_delete_binding (VTE_TERMINAL(tt->vte_term), VTE_ERASE_ASCII_BACKSPACE); break; case AUTO: default: vte_terminal_set_delete_binding (VTE_TERMINAL(tt->vte_term), VTE_ERASE_AUTO); break; } /** Word chars **/ word_chars = config_getstr ("word_chars"); if (NULL == word_chars || '\0' == *word_chars) { word_chars = DEFAULT_WORD_CHARS; } vte_terminal_set_word_chars (VTE_TERMINAL(tt->vte_term), word_chars); /** Background **/ if (config_getbool ("use_image")) vte_terminal_set_background_image_file (VTE_TERMINAL(tt->vte_term), config_getstr ("image")); else vte_terminal_set_background_image_file (VTE_TERMINAL(tt->vte_term), NULL); transparency_level = ((gdouble) config_getint ("transparency"))/100; if (config_getbool ("enable_transparency") && transparency_level > 0) { vte_terminal_set_background_saturation (VTE_TERMINAL (tt->vte_term), transparency_level); vte_terminal_set_opacity (VTE_TERMINAL (tt->vte_term), (1.0 - transparency_level) * 0xffff); vte_terminal_set_background_transparent (VTE_TERMINAL(tt->vte_term), !tt->tw->have_argb_visual); } return 0; }
static VALUE term_set_scrollback_lines(VALUE self, VALUE lines) { vte_terminal_set_scrollback_lines(RVAL2TERM(self), NUM2LONG(lines)); return Qnil; }
int main (int argc, char *argv[]) { GtkWidget *window, *terminal, *scrollbar, *design; GError *icon_error = NULL; GdkPixbuf *icon; GdkGeometry geo_hints; /* Init gtk and all widgets */ gtk_init (&argc, &argv); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); terminal = vte_terminal_new (); scrollbar = gtk_vscrollbar_new (VTE_TERMINAL (terminal)->adjustment); design = gtk_hbox_new (FALSE, 0); /* Set window icon */ icon = gdk_pixbuf_new_from_file (TINYTERM_ICON_PATH, &icon_error); if (!icon) { fprintf (stderr, "%s\n", icon_error->message); g_error_free (icon_error); } gtk_window_set_icon (GTK_WINDOW (window), icon); /* Set window title */ gtk_window_set_title (GTK_WINDOW (window), "TinyTerm"); /* Set scrollback lines */ vte_terminal_set_scrollback_lines (VTE_TERMINAL (terminal), TINYTERM_SCROLLBACK_LINES); /* Apply geometry hints to handle terminal resizing */ geo_hints.base_width = VTE_TERMINAL (terminal)->char_width; geo_hints.base_height = VTE_TERMINAL (terminal)->char_height; geo_hints.min_width = VTE_TERMINAL (terminal)->char_width; geo_hints.min_height = VTE_TERMINAL (terminal)->char_height; geo_hints.width_inc = VTE_TERMINAL (terminal)->char_width; geo_hints.height_inc = VTE_TERMINAL (terminal)->char_height; gtk_window_set_geometry_hints (GTK_WINDOW (window), terminal, &geo_hints, GDK_HINT_RESIZE_INC | GDK_HINT_MIN_SIZE | GDK_HINT_BASE_SIZE); /* Open a standard shell */ vte_terminal_fork_command (VTE_TERMINAL (terminal), NULL, // binary to run (NULL=user's shell) NULL, // arguments NULL, // environment NULL, // dir to start (NULL=CWD) TRUE, // log session to lastlog TRUE, // log session to utmp/utmpx log TRUE); // log session to wtmp/wtmpx log /* Connect signals */ g_signal_connect (window, "delete-event", gtk_main_quit, NULL); g_signal_connect (terminal, "child-exited", gtk_main_quit, NULL); g_signal_connect (terminal, "key-press-event", G_CALLBACK (on_key_press), NULL); /* Set selection behavior for double-clicks */ vte_terminal_set_word_chars (VTE_TERMINAL (terminal), TINYTERM_WORD_CHARS); /* Put all widgets together and show the result */ gtk_box_pack_start (GTK_BOX (design), terminal, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (design), scrollbar, FALSE, FALSE, 0); gtk_container_add (GTK_CONTAINER (window), design); gtk_widget_show_all (window); gtk_main (); return 0; }
console_t *uimon_window_open(void) { GtkWidget *scrollbar, *horizontal_container; GdkGeometry hints; if (fixed.window == NULL) { fixed.window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(fixed.window), "VICE monitor"); gtk_window_set_position(GTK_WINDOW(fixed.window), GTK_WIN_POS_CENTER); gtk_widget_set_app_paintable(fixed.window, TRUE); gtk_window_set_deletable(GTK_WINDOW(fixed.window), TRUE); fixed.term = vte_terminal_new(); vte_terminal_set_scrollback_lines (VTE_TERMINAL(fixed.term), 1000); vte_terminal_set_scroll_on_output (VTE_TERMINAL(fixed.term), TRUE); /* allowed window widths are base_width + width_inc * N * allowed window heights are base_height + height_inc * N */ hints.width_inc = vte_terminal_get_char_width (VTE_TERMINAL(fixed.term)); hints.height_inc = vte_terminal_get_char_height (VTE_TERMINAL(fixed.term)); /* min size should be multiple of .._inc, else we get funky effects */ hints.min_width = hints.width_inc; hints.min_height = hints.height_inc; /* base size should be multiple of .._inc, else we get funky effects */ hints.base_width = hints.width_inc; hints.base_height = hints.height_inc; gtk_window_set_geometry_hints (GTK_WINDOW (fixed.window), fixed.term, &hints, GDK_HINT_RESIZE_INC | GDK_HINT_MIN_SIZE | GDK_HINT_BASE_SIZE); #if GTK_CHECK_VERSION (2, 91, 1) { glong width, height; get_terminal_size_in_chars(VTE_TERMINAL(fixed.term), &width, &height); gtk_window_resize_to_geometry (GTK_WINDOW (fixed.window), width, height); } #endif scrollbar = gtk_vscrollbar_new(vte_terminal_get_adjustment (VTE_TERMINAL(fixed.term))); horizontal_container = gtk_hbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(fixed.window), horizontal_container); gtk_container_add(GTK_CONTAINER(horizontal_container), fixed.term); gtk_container_add(GTK_CONTAINER(horizontal_container), scrollbar); g_signal_connect(G_OBJECT(fixed.window), "delete-event", G_CALLBACK(close_window), &fixed.input_buffer); g_signal_connect(G_OBJECT(fixed.term), "key-press-event", G_CALLBACK(key_press_event), &fixed.input_buffer); g_signal_connect(G_OBJECT(fixed.term), "button-press-event", G_CALLBACK(button_press_event), &fixed.input_buffer); g_signal_connect (fixed.term, "text-modified", G_CALLBACK (screen_resize_window_cb), NULL); vte_console.console_can_stay_open = 1; } return uimon_window_resume(); }
static void terminal_set_preferences (VteTerminal *term, GSettings* settings, TerminalPlugin *term_plugin) { char *text; int value; gboolean setting; GdkColor color[2]; GdkColor* foreground; GdkColor* background; gchar *profile; g_return_if_fail (settings != NULL); #if 0 /* Update the currently available list of terminal profiles */ setting = g_settings_get_boolean (settings, PREFS_TERMINAL_PROFILE_USE_DEFAULT); if (setting) { // TODO: Get from GSettings instead of GConf /* Use the currently selected profile in gnome-terminal */ text = gconf_client_get_string (client, GCONF_DEFAULT_PROFILE, NULL); } else { /* Otherwise use the user selected profile */ text = g_settings_get_string (settings, PREFS_TERMINAL_PROFILE); } if (!text || (*text == '\0')) text = g_strdup ("Default"); profile = text; vte_terminal_set_mouse_autohide (term, TRUE); /* Set terminal font either using the desktop wide font or g-t one. */ setting = g_settings_get_boolean (GCONF_USE_SYSTEM_FONT); if (setting) { text = gconf_client_get_string (client, GCONF_MONOSPACE_FONT, NULL); if (!text) text = GET_PROFILE_STRING (GCONF_VTE_TERMINAL_FONT); } else { text = GET_PROFILE_STRING (GCONF_VTE_TERMINAL_FONT); } if (text) vte_terminal_set_font_from_string (term, text); g_free (text); setting = GET_PROFILE_BOOL (GCONF_CURSOR_BLINK); vte_terminal_set_cursor_blink_mode ((term), setting ? VTE_CURSOR_BLINK_ON : VTE_CURSOR_BLINK_OFF); setting = GET_PROFILE_BOOL (GCONF_SILENT_BELL); vte_terminal_set_audible_bell (term, !setting); value = GET_PROFILE_INT (GCONF_SCROLLBACK_LINES); vte_terminal_set_scrollback_lines (term, (value == 0) ? 500 : value); setting = GET_PROFILE_BOOL (GCONF_SCROLL_ON_KEYSTROKE); vte_terminal_set_scroll_on_keystroke (term, setting); setting = GET_PROFILE_BOOL (GCONF_SCROLL_ON_OUTPUT); vte_terminal_set_scroll_on_output (term, TRUE); text = GET_PROFILE_STRING (GCONF_WORD_CHARS); if (text) vte_terminal_set_word_chars (term, text); g_free (text); text = GET_PROFILE_STRING (GCONF_BACKSPACE_BINDING); if (text) { if (!strcmp (text, "ascii-del")) vte_terminal_set_backspace_binding (term, VTE_ERASE_ASCII_DELETE); else if (!strcmp (text, "escape-sequence")) vte_terminal_set_backspace_binding (term, VTE_ERASE_DELETE_SEQUENCE); else if (!strcmp (text, "control-h")) vte_terminal_set_backspace_binding (term, VTE_ERASE_ASCII_BACKSPACE); else vte_terminal_set_backspace_binding (term, VTE_ERASE_AUTO); g_free (text); } text = GET_PROFILE_STRING (GCONF_DELETE_BINDING); if (text) { if (!strcmp (text, "ascii-del")) vte_terminal_set_delete_binding (term, VTE_ERASE_ASCII_DELETE); else if (!strcmp (text, "escape-sequence")) vte_terminal_set_delete_binding (term, VTE_ERASE_DELETE_SEQUENCE); else if (!strcmp (text, "control-h")) vte_terminal_set_delete_binding (term, VTE_ERASE_ASCII_BACKSPACE); else vte_terminal_set_delete_binding (term, VTE_ERASE_AUTO); g_free (text); } /* Set fore- and background colors. */ text = GET_PROFILE_STRING (GCONF_BACKGROUND_COLOR); if (text) { gdk_color_parse (text, &color[0]); g_free (text); } background = text ? &color[0] : NULL; text = GET_PROFILE_STRING (GCONF_FOREGROUND_COLOR); if (text) { gdk_color_parse (text, &color[1]); g_free (text); } foreground = text ? &color[1] : NULL; /* vte_terminal_set_colors works even if the terminal widget is not realized * which is not the case with vte_terminal_set_color_foreground and * vte_terminal_set_color_background */ vte_terminal_set_colors (term, foreground, background, NULL, 0); /* vte_terminal is not working depending on update_records setting at least * on FreeBSD */ term_plugin->lastlog = GET_PROFILE_BOOL (GCONF_LOGIN_SHELL); term_plugin->update_records = GET_PROFILE_BOOL_DEFAULT (GCONF_UPDATE_RECORDS, TRUE); g_free (profile); g_object_unref (client); #endif }
// to init a new page void init_new_page(struct Window *win_data, struct Page *page_data, glong column, glong row) { #ifdef DETAIL g_debug("! Launch init_new_page() with win_data = %p, page_data = %p, " " column = %ld, row = %ld", win_data, page_data, column, row); #endif #ifdef SAFEMODE if ((win_data==NULL) || (page_data==NULL) || (page_data->vte==NULL)) return; #endif // g_debug("Get win_data = %d when initing new page!", win_data); #ifdef SAFEMODE if (page_data->font_name) { #endif // set font // g_debug("Set Font AA = %d", win_data->font_anti_alias); vte_terminal_set_font_from_string_full (VTE_TERMINAL(page_data->vte), page_data->font_name, win_data->font_anti_alias); #ifdef SAFEMODE } #endif //g_debug("Got font size from %s: %d", font_name, pango_font_description_get_size ( // pango_font_description_from_string(font_name))/PANGO_SCALE); // set terminal size // g_debug("Set the vte size to: %dx%d", column, row); #ifdef SAFEMODE if (page_data->vte) #endif vte_terminal_set_size(VTE_TERMINAL(page_data->vte), column, row); #ifdef GEOMETRY # ifdef USE_GTK2_GEOMETRY_METHOD g_debug("@ init_new_page(for %p, vte = %p): Set win_data->keep_vte_size to %d, and column = %ld, row = %ld", win_data->window, page_data->vte, win_data->keep_vte_size, column, row); # else g_debug("@ init_new_page(for %p, vte = %p): Set column = %ld, row = %ld", win_data->window, page_data->vte, column, row); # endif #endif set_vte_color(page_data->vte, use_default_vte_theme(win_data), win_data->cursor_color, win_data->color, FALSE); // set transparent set_background_saturation(NULL, 0, win_data->background_saturation, page_data->vte); // other settings vte_terminal_set_word_chars(VTE_TERMINAL(page_data->vte), win_data->word_chars); vte_terminal_set_scrollback_lines(VTE_TERMINAL(page_data->vte), win_data->scrollback_lines); // some fixed parameter vte_terminal_set_scroll_on_output(VTE_TERMINAL(page_data->vte), FALSE); vte_terminal_set_scroll_on_keystroke(VTE_TERMINAL(page_data->vte), TRUE); // vte_terminal_set_backspace_binding (VTE_TERMINAL(page_data->vte), VTE_ERASE_ASCII_DELETE); // vte_terminal_set_delete_binding (VTE_TERMINAL(page_data->vte), VTE_ERASE_ASCII_DELETE); // vte_terminal_set_emulation (VTE_TERMINAL(page_data->vte), "xterm"); #ifdef ENABLE_FIND_STRING vte_terminal_search_set_wrap_around (VTE_TERMINAL(page_data->vte), TRUE); #endif set_hyprelink(win_data, page_data); set_cursor_blink(win_data, page_data); vte_terminal_set_allow_bold(VTE_TERMINAL(page_data->vte), win_data->allow_bold_text); vte_terminal_set_audible_bell (VTE_TERMINAL(page_data->vte), win_data->audible_bell); vte_terminal_set_visible_bell (VTE_TERMINAL(page_data->vte), win_data->visible_bell); // g_debug("init_new_page(): call set_vte_urgent_bell()"); #ifdef ENABLE_BEEP_SINGAL set_vte_urgent_bell(win_data, page_data); #endif vte_terminal_set_backspace_binding (VTE_TERMINAL(page_data->vte), win_data->erase_binding); #ifdef ENABLE_CURSOR_SHAPE vte_terminal_set_cursor_shape(VTE_TERMINAL(page_data->vte), win_data->cursor_shape); #endif vte_terminal_set_emulation (VTE_TERMINAL(page_data->vte), win_data->emulate_term); }
void termit_append_tab_with_details(const struct TabInfo* ti) { struct TermitTab* pTab = g_malloc0(sizeof(struct TermitTab)); termit_style_copy(&pTab->style, &configs.style); if (ti->name) { pTab->tab_name = gtk_label_new(ti->name); pTab->custom_tab_name = TRUE; } else { gchar* label_text = g_strdup_printf("%s %d", configs.default_tab_name, termit.tab_max_number++); pTab->tab_name = gtk_label_new(label_text); g_free(label_text); pTab->custom_tab_name = FALSE; } pTab->encoding = (ti->encoding) ? g_strdup(ti->encoding) : g_strdup(configs.default_encoding); pTab->bksp_binding = ti->bksp_binding; pTab->delete_binding = ti->delete_binding; pTab->hbox = gtk_hbox_new(FALSE, 0); pTab->vte = vte_terminal_new(); vte_terminal_set_scrollback_lines(VTE_TERMINAL(pTab->vte), configs.scrollback_lines); if (configs.default_word_chars) vte_terminal_set_word_chars(VTE_TERMINAL(pTab->vte), configs.default_word_chars); vte_terminal_set_mouse_autohide(VTE_TERMINAL(pTab->vte), TRUE); vte_terminal_set_backspace_binding(VTE_TERMINAL(pTab->vte), pTab->bksp_binding); vte_terminal_set_delete_binding(VTE_TERMINAL(pTab->vte), pTab->delete_binding); #ifdef TERMIT_ENABLE_SEARCH vte_terminal_search_set_wrap_around(VTE_TERMINAL(pTab->vte), TRUE); #endif // TERMIT_ENABLE_SEARCH /* parse command */ gchar **cmd_argv; GError *cmd_err = NULL; gchar *cmd_path = NULL; gchar *cmd_file = NULL; pTab->command = (ti->command) ? g_strdup(ti->command) : g_strdup(configs.default_command); if (!g_shell_parse_argv(pTab->command, NULL, &cmd_argv, &cmd_err)) { ERROR("%s", _("Cannot parse command. Creating tab with shell")); g_error_free(cmd_err); } else { cmd_path = g_find_program_in_path(cmd_argv[0]); cmd_file = g_path_get_basename(cmd_argv[0]); } TRACE("command=%s cmd_path=%s cmd_file=%s", pTab->command, cmd_path, cmd_file); if (cmd_path && cmd_file) { g_free(cmd_argv[0]); cmd_argv[0] = g_strdup(cmd_path); #if VTE_CHECK_VERSION(0, 26, 0) > 0 if (vte_terminal_fork_command_full(VTE_TERMINAL(pTab->vte), VTE_PTY_DEFAULT, ti->working_dir, cmd_argv, NULL, 0, NULL, NULL, &pTab->pid, &cmd_err) != TRUE) { ERROR("failed to open tab: %s", cmd_err->message); g_error_free(cmd_err); } #else pTab->pid = vte_terminal_fork_command(VTE_TERMINAL(pTab->vte), cmd_path, cmd_argv, NULL, ti->working_dir, TRUE, TRUE, TRUE); #endif // version >= 0.26 } else { g_free(pTab->command); pTab->command = g_strdup(configs.default_command); gchar* argv[] = {pTab->command, NULL}; TRACE("defaults: cmd=%s working_dir=%s", pTab->command, ti->working_dir); /* default tab */ #if VTE_CHECK_VERSION(0, 26, 0) > 0 if (vte_terminal_fork_command_full(VTE_TERMINAL(pTab->vte), VTE_PTY_DEFAULT, ti->working_dir, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, &pTab->pid, &cmd_err) != TRUE) { ERROR("failed to open tab: %s", cmd_err->message); g_error_free(cmd_err); } #else pTab->pid = vte_terminal_fork_command(VTE_TERMINAL(pTab->vte), pTab->command, NULL, NULL, ti->working_dir, TRUE, TRUE, TRUE); #endif // version >= 0.26 } g_strfreev(cmd_argv); g_free(cmd_path); g_free(cmd_file); g_signal_connect(G_OBJECT(pTab->vte), "beep", G_CALLBACK(termit_on_beep), pTab); g_signal_connect(G_OBJECT(pTab->vte), "focus-in-event", G_CALLBACK(termit_on_focus), pTab); g_signal_connect(G_OBJECT(pTab->vte), "window-title-changed", G_CALLBACK(termit_on_tab_title_changed), NULL); g_signal_connect(G_OBJECT(pTab->vte), "child-exited", G_CALLBACK(termit_on_child_exited), NULL); // g_signal_connect(G_OBJECT(pTab->vte), "eof", G_CALLBACK(termit_eof), NULL); g_signal_connect_swapped(G_OBJECT(pTab->vte), "button-press-event", G_CALLBACK(termit_on_popup), NULL); vte_terminal_set_encoding(VTE_TERMINAL(pTab->vte), pTab->encoding); pTab->matches = g_array_new(FALSE, TRUE, sizeof(struct Match)); termit_tab_add_matches(pTab, configs.matches); termit_tab_set_transparency(pTab, pTab->style.transparency); vte_terminal_set_font(VTE_TERMINAL(pTab->vte), pTab->style.font); gint index = gtk_notebook_append_page(GTK_NOTEBOOK(termit.notebook), pTab->hbox, pTab->tab_name); if (index == -1) { ERROR("%s", _("Cannot create a new tab")); return; } if (configs.fill_tabbar) { GValue val = {}; g_value_init(&val, G_TYPE_BOOLEAN); g_value_set_boolean(&val, TRUE); gtk_container_child_set_property(GTK_CONTAINER(termit.notebook), pTab->hbox, "tab-expand", &val); gtk_container_child_set_property(GTK_CONTAINER(termit.notebook), pTab->hbox, "tab-fill", &val); } termit_tab_set_audible_bell(pTab, configs.audible_bell); termit_tab_set_visible_bell(pTab, configs.visible_bell); pTab->scrollbar = gtk_vscrollbar_new(vte_terminal_get_adjustment(VTE_TERMINAL(pTab->vte))); gtk_box_pack_start(GTK_BOX(pTab->hbox), pTab->vte, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(pTab->hbox), pTab->scrollbar, FALSE, FALSE, 0); GtkWidget* tabWidget = gtk_notebook_get_nth_page(GTK_NOTEBOOK(termit.notebook), index); if (!tabWidget) { ERROR("tabWidget is NULL"); return; } g_object_set_data(G_OBJECT(tabWidget), TERMIT_TAB_DATA, pTab); if (index == 0) { // there is no "switch-page" signal on the first page termit_set_statusbar_message(index); } pTab->scrollbar_is_shown = configs.show_scrollbar; gtk_widget_show_all(termit.notebook); if (pTab->style.image_file == NULL) { vte_terminal_set_background_image(VTE_TERMINAL(pTab->vte), NULL); } else { vte_terminal_set_background_image_file(VTE_TERMINAL(pTab->vte), pTab->style.image_file); } termit_tab_apply_colors(pTab); gtk_notebook_set_current_page(GTK_NOTEBOOK(termit.notebook), index); gtk_notebook_set_tab_reorderable(GTK_NOTEBOOK(termit.notebook), pTab->hbox, TRUE); gtk_window_set_focus(GTK_WINDOW(termit.main_window), pTab->vte); termit_check_single_tab(); termit_hide_scrollbars(); }
int main(int argc, char **argv) { GdkScreen *screen; GdkColormap *colormap; GtkWidget *window, *widget,*hbox = NULL, *scrollbar, *scrolled_window = NULL; VteTerminal *terminal; char *env_add[] = { #ifdef VTE_DEBUG (char *) "FOO=BAR", (char *) "BOO=BIZ", #endif NULL}; const char *background = NULL; gboolean transparent = FALSE, audible = TRUE, blink = TRUE, debug = FALSE, dingus = FALSE, dbuffer = TRUE, console = FALSE, scroll = FALSE, keep = FALSE, icon_title = FALSE, shell = TRUE, highlight_set = FALSE, cursor_set = FALSE, reverse = FALSE, use_geometry_hints = TRUE, antialias = TRUE, use_scrolled_window = FALSE, show_object_notifications = FALSE; char *geometry = NULL; gint lines = 100; const char *message = "Launching interactive shell...\r\n"; const char *font = NULL; const char *termcap = NULL; const char *command = NULL; const char *working_directory = NULL; const char *output_file = NULL; char *pty_flags_string = NULL; char *cursor_shape_string = NULL; char *scrollbar_policy_string = NULL; GdkColor fore, back, tint, highlight, cursor; const GOptionEntry options[]={ { "antialias", 'A', G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &antialias, "Disable the use of anti-aliasing", NULL }, { "background", 'B', 0, G_OPTION_ARG_FILENAME, &background, "Specify a background image", NULL }, { "console", 'C', 0, G_OPTION_ARG_NONE, &console, "Watch /dev/console", NULL }, { "dingus", 'D', 0, G_OPTION_ARG_NONE, &dingus, "Highlight URLs inside the terminal", NULL }, { "shell", 'S', G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &shell, "Disable spawning a shell inside the terminal", NULL }, { "transparent", 'T', 0, G_OPTION_ARG_NONE, &transparent, "Enable the use of a transparent background", NULL }, { "double-buffer", '2', G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &dbuffer, "Disable double-buffering", NULL }, { "audible", 'a', G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &audible, "Use visible, instead of audible, terminal bell", NULL }, { "blink", 'b', G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &blink, "Disable the blinking cursor", NULL }, { "command", 'c', 0, G_OPTION_ARG_STRING, &command, "Execute a command in the terminal", NULL }, { "debug", 'd', 0, G_OPTION_ARG_NONE, &debug, "Enable various debugging checks", NULL }, { "font", 'f', 0, G_OPTION_ARG_STRING, &font, "Specify a font to use", NULL }, { "geometry", 'g', 0, G_OPTION_ARG_STRING, &geometry, "Set the size (in characters) and position", "GEOMETRY" }, { "highlight", 'h', 0, G_OPTION_ARG_NONE, &highlight_set, "Enable the cursor highlighting", NULL }, { "icon-title", 'i', 0, G_OPTION_ARG_NONE, &icon_title, "Enable the setting of the icon title", NULL }, { "keep", 'k', 0, G_OPTION_ARG_NONE, &keep, "Live on after the window closes", NULL }, { "scrollback-lines", 'n', 0, G_OPTION_ARG_INT, &lines, "Specify the number of scrollback-lines", NULL }, { "color-cursor", 'r', 0, G_OPTION_ARG_NONE, &cursor_set, "Enable a colored cursor", NULL }, { "cursor-shape", 0, 0, G_OPTION_ARG_STRING, &cursor_shape_string, "Set cursor shape (block|underline|ibeam)", NULL }, { "scroll-background", 's', 0, G_OPTION_ARG_NONE, &scroll, "Enable a scrolling background", NULL }, { "termcap", 't', 0, G_OPTION_ARG_STRING, &termcap, "Specify the terminal emulation to use", NULL }, { "working-directory", 'w', 0, G_OPTION_ARG_FILENAME, &working_directory, "Specify the initial working directory of the terminal", NULL }, { "reverse", 0, 0, G_OPTION_ARG_NONE, &reverse, "Reverse foreground/background colors", NULL }, { "no-geometry-hints", 'G', G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &use_geometry_hints, "Allow the terminal to be resized to any dimension, not constrained to fit to an integer multiple of characters", NULL }, { "scrolled-window", 'W', 0, G_OPTION_ARG_NONE, &use_scrolled_window, "Use a GtkScrolledWindow as terminal container", NULL }, { "scrollbar-policy", 'P', 0, G_OPTION_ARG_STRING, &scrollbar_policy_string, "Set the policy for the vertical scroolbar in the scrolled window (always|auto|never; default:always)", NULL }, { "object-notifications", 'N', 0, G_OPTION_ARG_NONE, &show_object_notifications, "Print VteTerminal object notifications", NULL }, { "output-file", 0, 0, G_OPTION_ARG_STRING, &output_file, "Save terminal contents to file at exit", NULL }, { "pty-flags", 0, 0, G_OPTION_ARG_STRING, &pty_flags_string, "PTY flags set from default|no-utmp|no-wtmp|no-lastlog|no-helper|no-fallback", NULL }, { NULL } }; GOptionContext *context; GError *error = NULL; VteTerminalCursorShape cursor_shape = VTE_CURSOR_SHAPE_BLOCK; GtkPolicyType scrollbar_policy = GTK_POLICY_ALWAYS; VtePtyFlags pty_flags = VTE_PTY_DEFAULT; /* Have to do this early. */ if (getenv("VTE_PROFILE_MEMORY")) { if (atol(getenv("VTE_PROFILE_MEMORY")) != 0) { g_mem_set_vtable(glib_mem_profiler_table); } } context = g_option_context_new (" - test VTE terminal emulation"); g_option_context_add_main_entries (context, options, NULL); g_option_context_add_group (context, gtk_get_option_group (TRUE)); g_option_context_parse (context, &argc, &argv, &error); g_option_context_free (context); if (error != NULL) { g_printerr ("Failed to parse command line arguments: %s\n", error->message); g_error_free (error); return 1; } if (cursor_shape_string) { cursor_shape = parse_enum(VTE_TYPE_TERMINAL_CURSOR_SHAPE, cursor_shape_string); g_free(cursor_shape_string); } if (scrollbar_policy_string) { scrollbar_policy = parse_enum(GTK_TYPE_POLICY_TYPE, scrollbar_policy_string); g_free(scrollbar_policy_string); } if (pty_flags_string) { pty_flags |= parse_flags(VTE_TYPE_PTY_FLAGS, pty_flags_string); g_free(pty_flags_string); } if (!reverse) { back.red = back.green = back.blue = 0xffff; fore.red = fore.green = fore.blue = 0x0000; } else { back.red = back.green = back.blue = 0x0000; fore.red = fore.green = fore.blue = 0xffff; } highlight.red = highlight.green = highlight.blue = 0xc000; cursor.red = 0xffff; cursor.green = cursor.blue = 0x8000; tint.red = tint.green = tint.blue = 0; tint = back; gdk_window_set_debug_updates(debug); /* Create a window to hold the scrolling shell, and hook its * delete event to the quit function.. */ window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_container_set_resize_mode(GTK_CONTAINER(window), GTK_RESIZE_IMMEDIATE); /* Set ARGB colormap */ screen = gtk_widget_get_screen (window); colormap = gdk_screen_get_rgba_colormap (screen); if (colormap) gtk_widget_set_colormap(window, colormap); if (use_scrolled_window) { scrolled_window = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), GTK_POLICY_NEVER, scrollbar_policy); gtk_container_add(GTK_CONTAINER(window), scrolled_window); } else { /* Create a box to hold everything. */ hbox = gtk_hbox_new(0, FALSE); gtk_container_add(GTK_CONTAINER(window), hbox); } /* Create the terminal widget and add it to the scrolling shell. */ widget = vte_terminal_new(); terminal = VTE_TERMINAL (widget); if (!dbuffer) { gtk_widget_set_double_buffered(widget, dbuffer); } g_signal_connect(terminal, "child-exited", G_CALLBACK(child_exit_cb), NULL); if (show_object_notifications) g_signal_connect(terminal, "notify", G_CALLBACK(terminal_notify_cb), NULL); if (use_scrolled_window) { gtk_container_add(GTK_CONTAINER(scrolled_window), GTK_WIDGET(terminal)); } else { gtk_box_pack_start(GTK_BOX(hbox), widget, TRUE, TRUE, 0); } /* Connect to the "char_size_changed" signal to set geometry hints * whenever the font used by the terminal is changed. */ if (use_geometry_hints) { char_size_changed(widget, 0, 0, window); g_signal_connect(widget, "char-size-changed", G_CALLBACK(char_size_changed), window); g_signal_connect(widget, "realize", G_CALLBACK(char_size_realized), window); } /* Connect to the "window_title_changed" signal to set the main * window's title. */ g_signal_connect(widget, "window-title-changed", G_CALLBACK(window_title_changed), window); if (icon_title) { g_signal_connect(widget, "icon-title-changed", G_CALLBACK(icon_title_changed), window); } /* Connect to the "status-line-changed" signal. */ g_signal_connect(widget, "status-line-changed", G_CALLBACK(status_line_changed), widget); /* Connect to the "button-press" event. */ g_signal_connect(widget, "button-press-event", G_CALLBACK(button_pressed), widget); /* Connect to application request signals. */ g_signal_connect(widget, "iconify-window", G_CALLBACK(iconify_window), window); g_signal_connect(widget, "deiconify-window", G_CALLBACK(deiconify_window), window); g_signal_connect(widget, "raise-window", G_CALLBACK(raise_window), window); g_signal_connect(widget, "lower-window", G_CALLBACK(lower_window), window); g_signal_connect(widget, "maximize-window", G_CALLBACK(maximize_window), window); g_signal_connect(widget, "restore-window", G_CALLBACK(restore_window), window); g_signal_connect(widget, "refresh-window", G_CALLBACK(refresh_window), window); g_signal_connect(widget, "resize-window", G_CALLBACK(resize_window), window); g_signal_connect(widget, "move-window", G_CALLBACK(move_window), window); /* Connect to font tweakage. */ g_signal_connect(widget, "increase-font-size", G_CALLBACK(increase_font_size), window); g_signal_connect(widget, "decrease-font-size", G_CALLBACK(decrease_font_size), window); if (!use_scrolled_window) { /* Create the scrollbar for the widget. */ scrollbar = gtk_vscrollbar_new(terminal->adjustment); gtk_box_pack_start(GTK_BOX(hbox), scrollbar, FALSE, FALSE, 0); } /* Set some defaults. */ vte_terminal_set_audible_bell(terminal, audible); vte_terminal_set_visible_bell(terminal, !audible); vte_terminal_set_cursor_blink_mode(terminal, blink ? VTE_CURSOR_BLINK_SYSTEM : VTE_CURSOR_BLINK_OFF); vte_terminal_set_scroll_background(terminal, scroll); vte_terminal_set_scroll_on_output(terminal, FALSE); vte_terminal_set_scroll_on_keystroke(terminal, TRUE); vte_terminal_set_scrollback_lines(terminal, lines); vte_terminal_set_mouse_autohide(terminal, TRUE); if (background != NULL) { vte_terminal_set_background_image_file(terminal, background); } if (transparent) { vte_terminal_set_background_transparent(terminal, TRUE); } vte_terminal_set_background_tint_color(terminal, &tint); vte_terminal_set_colors(terminal, &fore, &back, NULL, 0); vte_terminal_set_opacity(terminal, 0xdddd); if (highlight_set) { vte_terminal_set_color_highlight(terminal, &highlight); } if (cursor_set) { vte_terminal_set_color_cursor(terminal, &cursor); } if (termcap != NULL) { vte_terminal_set_emulation(terminal, termcap); } vte_terminal_set_cursor_shape(terminal, cursor_shape); /* Set the default font. */ vte_terminal_set_font_from_string_full(terminal, font, antialias ? VTE_ANTI_ALIAS_USE_DEFAULT : VTE_ANTI_ALIAS_FORCE_DISABLE); /* Match "abcdefg". */ if (dingus) { int id; GRegex *regex; regex = g_regex_new (DINGUS1, 0, 0, NULL); id = vte_terminal_match_add_gregex(terminal, regex, 0); g_regex_unref (regex); vte_terminal_match_set_cursor_type(terminal, id, GDK_GUMBY); regex = g_regex_new (DINGUS2, 0, 0, NULL); id = vte_terminal_match_add_gregex(terminal, regex, 0); g_regex_unref (regex); vte_terminal_match_set_cursor_type(terminal, id, GDK_HAND1); } if (console) { /* Open a "console" connection. */ int consolefd = -1, yes = 1, watch; GIOChannel *channel; consolefd = open("/dev/console", O_RDONLY | O_NOCTTY); if (consolefd != -1) { /* Assume failure. */ console = FALSE; #ifdef TIOCCONS if (ioctl(consolefd, TIOCCONS, &yes) != -1) { /* Set up a listener. */ channel = g_io_channel_unix_new(consolefd); watch = g_io_add_watch(channel, G_IO_IN, read_and_feed, widget); g_signal_connect(widget, "eof", G_CALLBACK(disconnect_watch), GINT_TO_POINTER(watch)); g_signal_connect(widget, "child-exited", G_CALLBACK(disconnect_watch), GINT_TO_POINTER(watch)); g_signal_connect(widget, "realize", G_CALLBACK(take_xconsole_ownership), NULL); #ifdef VTE_DEBUG vte_terminal_feed(terminal, "Console log for ...\r\n", -1); #endif /* Record success. */ console = TRUE; } #endif } else { /* Bail back to normal mode. */ g_warning(_("Could not open console.\n")); close(consolefd); console = FALSE; } } if (!console) { if (shell) { GError *err = NULL; char **command_argv = NULL; int command_argc; GPid pid = -1; _VTE_DEBUG_IF(VTE_DEBUG_MISC) vte_terminal_feed(terminal, message, -1); if (command == NULL) command = "/bin/sh"; // FIXMEchpe if (command != NULL) { if (!g_shell_parse_argv(command, &command_argc, &command_argv, &err) || !vte_terminal_fork_command_full(terminal, pty_flags, NULL, command_argv, env_add, G_SPAWN_SEARCH_PATH, NULL, NULL, &pid, &err)) { g_warning("Failed to fork: %s\n", err->message); g_error_free(err); } else { g_print("Fork succeeded, PID %d\n", pid); } } g_strfreev(command_argv); #ifdef VTE_DEBUG if (command == NULL) { vte_terminal_feed_child(terminal, "pwd\n", -1); } #endif } else { long i; i = vte_terminal_forkpty(terminal, env_add, working_directory, TRUE, TRUE, TRUE); switch (i) { case -1: /* abnormal */ g_warning("Error in vte_terminal_forkpty(): %s", strerror(errno)); break; case 0: /* child */ for (i = 0; ; i++) { switch (i % 3) { case 0: case 1: g_print("%ld\n", i); break; case 2: g_printerr("%ld\n", i); break; } sleep(1); } _exit(0); break; default: g_print("Child PID is %ld (mine is %ld).\n", (long) i, (long) getpid()); /* normal */ break; } } } g_object_set_data (G_OBJECT (widget), "output_file", (gpointer) output_file); /* Go for it! */ g_signal_connect(widget, "child-exited", G_CALLBACK(child_exited), window); g_signal_connect(window, "delete-event", G_CALLBACK(delete_event), widget); add_weak_pointer(G_OBJECT(widget), &widget); add_weak_pointer(G_OBJECT(window), &window); gtk_widget_realize(widget); if (geometry) { if (!gtk_window_parse_geometry (GTK_WINDOW(window), geometry)) { g_warning (_("Could not parse the geometry spec passed to --geometry")); } } gtk_widget_show_all(window); gtk_main(); g_assert(widget == NULL); g_assert(window == NULL); if (keep) { while (TRUE) { sleep(60); } } return 0; }
void apply_new_win_data_to_page (struct Window *win_data_orig, struct Window *win_data, struct Page *page_data) { #ifdef DETAIL g_debug("! Launch apply_new_win_data_to_page() with win_data_orig = %p, win_data = %p, page_data = %p", win_data_orig, win_data, page_data); #endif #ifdef SAFEMODE if ((win_data_orig==NULL) || (win_data==NULL) || (page_data==NULL) || (page_data->vte==NULL)) return; #endif // if (win_data_orig->use_rgba != win_data->use_rgba) // init_rgba(win_data); #ifdef ENABLE_RGBA set_window_opacity (NULL, 0, win_data->window_opacity, win_data); #endif init_monitor_cmdline_datas(win_data, page_data); if (win_data_orig->enable_hyperlink != win_data->enable_hyperlink) set_hyprelink(win_data, page_data); // ---- the color used in vte ---- // gboolean update_color = FALSE; if (compare_color(&(win_data_orig->cursor_color), &(win_data->cursor_color)) || (win_data_orig->have_custom_color != win_data->have_custom_color) || (win_data_orig->use_custom_theme != win_data->use_custom_theme) || (win_data_orig->color_brightness != win_data->color_brightness)) update_color = TRUE; gint i; if (! update_color && (win_data->use_custom_theme)) { for (i=0; i<COLOR; i++) if (compare_color(&(win_data_orig->color[i]), &(win_data->color[i]))) update_color = TRUE; } if (update_color) set_vte_color(page_data->vte, use_default_vte_theme(win_data), win_data->cursor_color, win_data->color, FALSE); // ---- tabs on notebook ---- // if (win_data_orig->tabs_bar_position != win_data->tabs_bar_position) { if (win_data->tabs_bar_position) gtk_notebook_set_tab_pos(GTK_NOTEBOOK(win_data->notebook), GTK_POS_BOTTOM); else gtk_notebook_set_tab_pos(GTK_NOTEBOOK(win_data->notebook), GTK_POS_TOP); } // the fill_tabs_bar may not always work, so we should call set_fill_tabs_bar() every time. // if (win_data_orig->fill_tabs_bar != win_data->fill_tabs_bar) set_fill_tabs_bar(GTK_NOTEBOOK(win_data->notebook), win_data->fill_tabs_bar, page_data); if (win_data_orig->page_width != win_data->page_width) set_page_width(win_data, page_data); // g_debug("ORI: %d", win_data_orig->page_shows_current_cmdline || // win_data_orig->page_shows_current_dir || // win_data_orig->page_shows_window_title); // g_debug("NEW: %d", win_data->page_shows_current_cmdline || // win_data->page_shows_current_dir || // win_data->page_shows_window_title); if ((proc_exist) && ((page_data->page_update_method != PAGE_METHOD_NORMAL) || (win_data->page_shows_current_cmdline || win_data->page_shows_current_dir || win_data->page_shows_window_title))) { // FIXME: Is it necessary? if (page_data->page_update_method == PAGE_METHOD_WINDOW_TITLE) page_data->window_title_updated = 1; page_data->page_update_method = PAGE_METHOD_REFRESH; } // g_debug("page_data->page_update_method = %d", page_data->page_update_method); if (win_data->page_shows_window_title != win_data_orig->page_shows_window_title) add_remove_window_title_changed_signal(page_data); if (win_data->check_root_privileges != win_data_orig->check_root_privileges) { if (win_data->check_root_privileges) page_data->is_root = check_is_root(page_data->displayed_tpgid); else page_data->is_root = FALSE; // g_debug("apply_new_win_data_to_page(): page_data->is_root = %d", page_data->is_root); } if (page_data->is_bold) { if (page_data->vte == win_data->current_vte) { if (win_data->bold_current_page_name == FALSE) { page_data->is_bold = page_data->should_be_bold; if (win_data->bold_action_page_name == FALSE) page_data->is_bold = FALSE; } } else { if (win_data->bold_action_page_name == FALSE) page_data->is_bold = FALSE; } } else { if (page_data->vte == win_data->current_vte) page_data->is_bold = win_data->bold_current_page_name; else if (win_data->bold_action_page_name == TRUE) page_data->is_bold = page_data->should_be_bold; } if ((win_data_orig->window_title_shows_current_page != win_data->window_title_shows_current_page) || (win_data_orig->window_title_append_package_name != win_data->window_title_append_package_name)) { check_and_update_window_title(win_data, page_data->custom_window_title, page_data->page_no+1, page_data->custom_page_name, page_data->page_name); // g_debug("FINAL: New window title = %s", gtk_window_get_title(GTK_WINDOW(win_data->window))); } get_and_update_page_name(page_data, FALSE); if ((win_data_orig->show_close_button_on_tab != win_data->show_close_button_on_tab) || (win_data_orig->show_close_button_on_all_tabs != win_data->show_close_button_on_all_tabs)) show_close_button_on_tab(win_data, page_data); // ---- font ---- // if (win_data_orig->font_anti_alias != win_data->font_anti_alias) vte_terminal_set_font_from_string_full (VTE_TERMINAL(page_data->vte), page_data->font_name, win_data->font_anti_alias); // ---- other settings for init a vte ---- // if (compare_strings(win_data_orig->word_chars, win_data->word_chars, TRUE)) vte_terminal_set_word_chars(VTE_TERMINAL(page_data->vte), win_data->word_chars); if (win_data_orig->show_scroll_bar != win_data->show_scroll_bar) // hide_scroll_bar(win_data, page_data); show_and_hide_scroll_bar(page_data, check_show_or_hide_scroll_bar(win_data)); if (win_data_orig->scroll_bar_position != win_data->scroll_bar_position) { g_object_ref(page_data->vte); gtk_container_remove (GTK_CONTAINER(page_data->hbox), page_data->vte); g_object_ref(page_data->scroll_bar); gtk_container_remove (GTK_CONTAINER(page_data->hbox), page_data->scroll_bar); pack_vte_and_scroll_bar_to_hbox(win_data, page_data); g_object_unref(page_data->vte); g_object_unref(page_data->scroll_bar); } if (compare_color(&(win_data_orig->color[0]), &(win_data->color[0])) || (win_data_orig->transparent_background != win_data->transparent_background) || (win_data_orig->background_saturation != win_data->background_saturation) || (win_data_orig->scroll_background != win_data->scroll_background) || compare_strings (win_data_orig->background_image, win_data->background_image, TRUE)) set_background_saturation (NULL, 0, win_data->background_saturation, page_data->vte); if (win_data_orig->scrollback_lines != win_data->scrollback_lines) vte_terminal_set_scrollback_lines (VTE_TERMINAL(page_data->vte), win_data->scrollback_lines); if (win_data_orig->cursor_blinks != win_data->cursor_blinks) set_cursor_blink(win_data, page_data); if (win_data_orig->allow_bold_text != win_data->allow_bold_text) vte_terminal_set_allow_bold(VTE_TERMINAL(page_data->vte), win_data->allow_bold_text); if (win_data_orig->audible_bell != win_data->audible_bell) vte_terminal_set_audible_bell (VTE_TERMINAL(page_data->vte), win_data->audible_bell); if (win_data_orig->visible_bell != win_data->visible_bell) vte_terminal_set_visible_bell (VTE_TERMINAL(page_data->vte), win_data->visible_bell); #ifdef ENABLE_BEEP_SINGAL if (win_data_orig->urgent_bell != win_data->urgent_bell) set_vte_urgent_bell(win_data, page_data); #endif if (win_data_orig->erase_binding != win_data->erase_binding) vte_terminal_set_backspace_binding (VTE_TERMINAL(page_data->vte), win_data->erase_binding); #ifdef ENABLE_CURSOR_SHAPE if (win_data_orig->cursor_shape != win_data->cursor_shape) vte_terminal_set_cursor_shape(VTE_TERMINAL(page_data->vte), win_data->cursor_shape); #endif if (compare_strings(win_data_orig->emulate_term, win_data->emulate_term, TRUE)) vte_terminal_set_emulation (VTE_TERMINAL(page_data->vte), win_data->emulate_term); }