From 711986766ac05853aa17e80f4e2007fc649334b5 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Wed, 25 Mar 2009 12:58:55 +0000 Subject: [PATCH] Allow user configurability of the cursor shape. Patch from Jordan Callicoat. Closes LP #348244 --- doc/terminator_config.5 | 4 ++++ terminatorlib/config.py | 1 + terminatorlib/prefs_profile.py | 10 +++++++++- terminatorlib/terminatorterm.py | 3 +++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/doc/terminator_config.5 b/doc/terminator_config.5 index 373df105..f624fc5a 100644 --- a/doc/terminator_config.5 +++ b/doc/terminator_config.5 @@ -87,6 +87,10 @@ Default value: \fBTrue\fR Default colour of cursor, as a colour specification (can be HTML-style hex digits, or a colour name such as "red"). Default value: Current value of \fBforeground_color\fR .TP +.B cursor_shape +Default shape of cursor. Possibilities are "block", "ibeam", and "underline". +Default value: \fBblock\fR +.TP .B emulation Sets what type of terminal should be emulated. Default value: \fBxterm\fR diff --git a/terminatorlib/config.py b/terminatorlib/config.py index 5712e7bd..6d5913dd 100755 --- a/terminatorlib/config.py +++ b/terminatorlib/config.py @@ -71,6 +71,7 @@ Defaults = { 'backspace_binding' : 'ascii-del', 'delete_binding' : 'delete-sequence', 'cursor_blink' : True, + 'cursor_shape' : 'block', 'cursor_color' : '', 'emulation' : 'xterm', 'font' : 'Mono 10', diff --git a/terminatorlib/prefs_profile.py b/terminatorlib/prefs_profile.py index 21771733..44fb646c 100644 --- a/terminatorlib/prefs_profile.py +++ b/terminatorlib/prefs_profile.py @@ -8,7 +8,7 @@ import gtk, gobject class ProfileEditor: # lists of which settings to put in which tabs - appearance = ['titlebars', 'titletips', 'allow_bold', 'audible_bell', 'visible_bell', 'urgent_bell', 'force_no_bell', 'background_darkness', 'background_type', 'background_image', 'cursor_blink', 'font', 'scrollbar_position', 'scroll_background', 'use_system_font', 'use_theme_colors', 'enable_real_transparency'] + appearance = ['titlebars', 'titletips', 'allow_bold', 'audible_bell', 'visible_bell', 'urgent_bell', 'force_no_bell', 'background_darkness', 'background_type', 'background_image', 'cursor_blink', 'cursor_shape', 'font', 'scrollbar_position', 'scroll_background', 'use_system_font', 'use_theme_colors', 'enable_real_transparency'] colours = ['foreground_color','background_color', 'cursor_color', 'palette'] behaviour = ['backspace_binding', 'delete_binding', 'emulation', 'scroll_on_keystroke', 'scroll_on_output', 'scrollback_lines', 'focus', 'focus_on_close', 'exit_action', 'word_chars', 'mouse_autohide', 'use_custom_command', 'custom_command', 'http_proxy', 'encoding'] globals = ['fullscreen', 'maximise', 'borderless', 'handle_size', 'cycle_term_tab', 'close_button_on_tab', 'tab_position', 'copy_on_selection', 'extreme_tabs', 'try_posix_regexp'] @@ -51,6 +51,7 @@ class ProfileEditor: background_type = ['solid', 'image', 'transparent'] tab_position = ['top', 'bottom', 'left', 'right'] tab_position_gtk = {'top' : gtk.POS_TOP, 'bottom' : gtk.POS_BOTTOM, 'left' : gtk.POS_LEFT, 'right' : gtk.POS_RIGHT} + cursor_shape = ['block', 'ibeam', 'underline'] def __init__ (self, term): self.term = term @@ -201,6 +202,11 @@ class ProfileEditor: for item in self.tab_position: widget.append_text (item) widget.set_active (self.tab_position.index(value)) + elif key == 'cursor_shape': + widget = gtk.combo_box_new_text() + for item in self.cursor_shape: + widget.append_text (item) + widget.set_active (self.cursor_shape.index (value)) else: if type == "bool": widget = gtk.CheckButton () @@ -248,6 +254,8 @@ class ProfileEditor: bucket = self.background_type elif widget.name == 'tab_position': bucket = self.tab_position + elif widget.name == 'cursor_shape': + bucket = self.cursor_shape else: err("Unknown bucket type for %s" % widget.name) continue diff --git a/terminatorlib/terminatorterm.py b/terminatorlib/terminatorterm.py index 01b3d7af..4c9d66cb 100755 --- a/terminatorlib/terminatorterm.py +++ b/terminatorlib/terminatorterm.py @@ -677,6 +677,9 @@ text/plain if cursor_color != '': self._vte.set_color_cursor (gtk.gdk.color_parse (cursor_color)) + # Set cursor shape + self._vte.set_cursor_shape (vte.__dict__["CURSOR_SHAPE_" + self.conf.cursor_shape.upper ()]) + # Set our background image, transparency and type # Many thanks to the authors of gnome-terminal, on which this code is based. background_type = self.conf.background_type