topinambour 1.0.8 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/actions.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright 2016 Cédric LE MOIGNE, cedlemo@gmx.com
1
+ # Copyright 2016 Cedric LE MOIGNE, cedlemo@gmx.com
2
2
  # This file is part of Topinambour.
3
3
  #
4
4
  # Topinambour is free software: you can redistribute it and/or modify
@@ -37,9 +37,19 @@ module TopinambourActions
37
37
  action
38
38
  end
39
39
 
40
+ def self.generate_css_editor_action(application)
41
+ action = generate_action("css_editor") do |_act, _param|
42
+ application.windows[0].show_css_editor
43
+ end
44
+ action
45
+ end
46
+
40
47
  def self.generate_preferences_action(application)
41
48
  action = generate_action("preferences") do |_act, _param|
42
- puts "TODO"
49
+ dialog = TopinambourPreferences.generate_dialog(application.windows.first)
50
+
51
+ dialog.run
52
+ application.windows.first.notebook.current.grab_focus
43
53
  end
44
54
  action
45
55
  end
@@ -61,7 +71,7 @@ module TopinambourActions
61
71
  term.copy_clipboard
62
72
  else
63
73
  clipboard = Gtk::Clipboard.get_default(Gdk::Display.default)
64
- clipboard.text = term.last_match
74
+ clipboard.text = term.last_match unless term.last_match.nil?
65
75
  end
66
76
  end
67
77
  action
@@ -75,7 +85,7 @@ module TopinambourActions
75
85
  end
76
86
 
77
87
  def self.add_actions_to(application)
78
- %w(about preferences quit term_copy term_paste).each do |name|
88
+ %w(about preferences quit term_copy term_paste css_editor).each do |name|
79
89
  add_action_to(name, application)
80
90
  end
81
91
  end
data/lib/application.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright 2016 Cédric LE MOIGNE, cedlemo@gmx.com
1
+ # Copyright 2016 Cedric LE MOIGNE, cedlemo@gmx.com
2
2
  # This file is part of Topinambour.
3
3
  #
4
4
  # Topinambour is free software: you can redistribute it and/or modify
@@ -47,9 +47,9 @@ class TopinambourApplication < Gtk::Application
47
47
 
48
48
  begin
49
49
  load_custom_css_config
50
- rescue
51
- puts "Bad css file using default css"
52
- load_default_css_config
50
+ rescue => e
51
+ puts "Bad css file using default css, #{e.message}"
52
+ load_default_css_config # Use last workin Css instead
53
53
  end
54
54
  end
55
55
 
@@ -90,8 +90,8 @@ class TopinambourApplication < Gtk::Application
90
90
  if File.exist?(USR_CSS)
91
91
  begin
92
92
  load_custom_css_config
93
- rescue
94
- puts "Bad css file using default css"
93
+ rescue => e
94
+ puts "Bad css file using default css #{e.message}"
95
95
  load_default_css_config
96
96
  end
97
97
  else
@@ -1,4 +1,4 @@
1
- # Copyright 2015-2016 Cédric LE MOIGNE, cedlemo@gmx.com
1
+ # Copyright 2015-2016 Cedric LE MOIGNE, cedlemo@gmx.com
2
2
  # This file is part of Topinambour.
3
3
  #
4
4
  # Topinambour is free software: you can redistribute it and/or modify
@@ -55,11 +55,8 @@ class TopinambourColorSelector < Gtk::Box
55
55
 
56
56
  def apply_new_css_properties(toplevel, props)
57
57
  toplevel.application.update_css(props)
58
- toplevel.notebook.each do |tab|
59
- next unless tab.class == TopinambourTerminal
60
- tab.colors = @colors
61
- tab.apply_colors
62
- end
58
+ toplevel.notebook.send_to_all_terminals("colors=", [@colors])
59
+ toplevel.notebook.send_to_all_terminals("apply_colors", nil)
63
60
  end
64
61
 
65
62
  def generate_save_button
data/lib/css_editor.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright 2015-2016 Cédric LE MOIGNE, cedlemo@gmx.com
1
+ # Copyright 2015-2016 Cedric LE MOIGNE, cedlemo@gmx.com
2
2
  # This file is part of Topinambour.
3
3
  #
4
4
  # Topinambour is free software: you can redistribute it and/or modify
data/lib/css_handler.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright 2016 Cédric LE MOIGNE, cedlemo@gmx.com
1
+ # Copyright 2016 Cedric LE MOIGNE, cedlemo@gmx.com
2
2
  # This file is part of Topinambour.
3
3
  #
4
4
  # Topinambour is free software: you can redistribute it and/or modify
@@ -72,14 +72,19 @@ module CssHandler
72
72
  parsed_color ? true : false
73
73
  end
74
74
 
75
- def self.property_to_css_instructions(name, value)
76
- if value.class == String && color_property?(value)
77
- "#{name}: #{value}"
75
+ def self.value_to_css_value(value)
76
+ if value.class == String && color_property?(value)
77
+ "#{value}"
78
78
  elsif value.class == String
79
- %(#{name}: "#{value}")
79
+ %("#{value}")
80
80
  else
81
- "#{name}: #{value}"
81
+ "#{value}"
82
82
  end
83
+
84
+ end
85
+
86
+ def self.property_to_css_instructions(name, value)
87
+ "#{name}: #{value_to_css_value(value)}"
83
88
  end
84
89
 
85
90
  def self.props_with_name(tree, prop_name)
@@ -116,7 +121,7 @@ module CssHandler
116
121
  else
117
122
  tmp = ""
118
123
  if line_number == start_range.line
119
- tmp += line[0..(start_range.offset - 2)] + value
124
+ tmp += line[0..(start_range.offset - 2)] + value_to_css_value(value)
120
125
  end
121
126
  tmp += line[(end_range.offset - 1)..-1] if line_number == end_range.line
122
127
  tmp
data/lib/font_selector.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright 2015-2016 Cédric LE MOIGNE, cedlemo@gmx.com
1
+ # Copyright 2015-2016 Cedric LE MOIGNE, cedlemo@gmx.com
2
2
  # This file is part of Topinambour.
3
3
  #
4
4
  # Topinambour is free software: you can redistribute it and/or modify
@@ -45,9 +45,7 @@ class TopinambourFontSelector < Gtk::Box
45
45
  font = @window.notebook.current.font
46
46
  new_props["-TopinambourTerminal-font"] = font.to_s
47
47
  toplevel.application.update_css(new_props)
48
- toplevel.notebook.each do |tab|
49
- tab.set_font(font) if tab.class == TopinambourTerminal
50
- end
48
+ toplevel.notebook.send_to_all_terminals("set_font", font)
51
49
  toplevel.exit_overlay_mode
52
50
  end
53
51
  pack_start(save_button, :expand => false, :fill => false, :padding => 0)
data/lib/notebook.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright 2015-2016 Cédric LE MOIGNE, cedlemo@gmx.com
1
+ # Copyright 2015-2016 Cedric LE MOIGNE, cedlemo@gmx.com
2
2
  # This file is part of Topinambour.
3
3
  #
4
4
  # Topinambour is free software: you can redistribute it and/or modify
@@ -40,6 +40,7 @@ class TopinambourNotebook < Gtk::Notebook
40
40
  end
41
41
 
42
42
  set_show_tabs(false)
43
+ set_show_border(false)
43
44
  end
44
45
 
45
46
  def remove_all_pages
@@ -83,4 +84,11 @@ class TopinambourNotebook < Gtk::Notebook
83
84
  pix = surface.to_pixbuf(0, 0, w, h)
84
85
  current.preview = pix if pix
85
86
  end
87
+
88
+ def send_to_all_terminals(method_name, values)
89
+ each do |tab|
90
+ next unless tab.class == TopinambourTerminal
91
+ tab.send(method_name, *values)
92
+ end
93
+ end
86
94
  end
@@ -0,0 +1,185 @@
1
+ # Copyright 2016 Cedric LE MOIGNE, cedlemo@gmx.com
2
+ # This file is part of Topinambour.
3
+ #
4
+ # Topinambour is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # any later version.
8
+ #
9
+ # Topinambour is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with Topinambour. If not, see <http://www.gnu.org/licenses/>.
16
+ require "gtksourceview3"
17
+
18
+ module TopinambourPreferences
19
+ def self.generate_dialog(parent)
20
+ resource_file = "/com/github/cedlemo/topinambour/prefs-dialog.ui"
21
+ builder = Gtk::Builder.new(:resource => resource_file)
22
+ dialog = builder["Preferences_dialog"]
23
+ dialog.transient_for = parent
24
+ add_source_view_style_chooser(builder, parent)
25
+ add_actions(builder, parent)
26
+ connect_response(dialog, builder)
27
+ dialog
28
+ end
29
+
30
+ def self.connect_response(dialog, builder)
31
+ dialog.signal_connect "response" do |widget, response|
32
+ case response
33
+ when 1
34
+ on_apply_response(widget, builder)
35
+ else
36
+ widget.destroy
37
+ end
38
+ end
39
+ end
40
+
41
+ def self.on_apply_response(widget, builder)
42
+ props = get_all_properties(widget, builder)
43
+ toplevel = widget.transient_for
44
+ toplevel.application.update_css(props)
45
+ widget.destroy
46
+ end
47
+
48
+ def self.get_all_properties(widget, builder)
49
+ props = {}
50
+ props.merge!(get_source_view_style(builder))
51
+ props.merge!(get_entry_value(builder))
52
+ props.merge!(get_switch_values(builder))
53
+ props.merge!(get_spin_values(widget))
54
+ props.merge!(get_combo_values(builder))
55
+ end
56
+
57
+ def self.add_actions(builder, parent)
58
+ %w(audible_bell allow_bold scroll_on_output
59
+ scroll_on_keystroke rewrap_on_resize mouse_autohide).each do |prop_name|
60
+ gen_switch_actions(prop_name, builder, parent)
61
+ end
62
+ gen_entry_actions("shell", builder, parent)
63
+ %w(cursor_shape cursor_blink_mode backspace_binding
64
+ delete_binding).each do |prop_name|
65
+ gen_combobox_actions(prop_name, builder, parent)
66
+ end
67
+ gen_spinbuttons_actions(builder, parent)
68
+ end
69
+
70
+ def self.gen_switch_actions(property_name, builder, parent)
71
+ switch = builder["#{property_name}_switch"]
72
+ switch.active = parent.notebook.current.send("#{property_name}?")
73
+ switch.signal_connect "state-set" do |_widget, state|
74
+ parent.notebook.send_to_all_terminals("#{property_name}=", state)
75
+ false
76
+ end
77
+ end
78
+
79
+ def self.gen_entry_actions(property_name, builder, parent)
80
+ entry = builder["#{property_name}_entry"]
81
+ entry.text = parent.shell
82
+ entry.set_icon_from_icon_name(:secondary, "edit-clear")
83
+ entry.signal_connect("activate") { |widget| parent.shell = widget.text }
84
+
85
+ entry.signal_connect "icon-release" do |widget, position|
86
+ if position == :secondary
87
+ parent.shell = widget.text = parent.style_get_property(property_name)
88
+ end
89
+ end
90
+ end
91
+
92
+ def self.gen_combobox_actions(property_name, builder, parent)
93
+ combobox = builder["#{property_name}_sel"]
94
+ id = parent.notebook.current.send("#{property_name}").nick + "_id"
95
+ combobox.active_id = id
96
+ combobox.signal_connect "changed" do |widget|
97
+ value = widget.active_id.gsub(/_id/, "").to_sym
98
+ parent.notebook.send_to_all_terminals("#{property_name}=", value)
99
+ end
100
+ end
101
+
102
+ def self.gen_spinbuttons_actions(builder, parent)
103
+ width_spin = builder["width_spin"]
104
+ height_spin = builder["height_spin"]
105
+ width_spin.set_range(0, 2000)
106
+ height_spin.set_range(0, 1000)
107
+ width_spin.value, height_spin.value = parent.size
108
+ gen_width_button_action(width_spin, parent)
109
+ gen_height_button_action(height_spin, parent)
110
+ end
111
+
112
+ def self.gen_width_button_action(spin_widget, parent)
113
+ spin_widget.signal_connect "value-changed" do |widget|
114
+ _, h = parent.size
115
+ parent.resize(widget.value, h)
116
+ w, _h = parent.size
117
+ widget.value = w if widget.value + 1 < w
118
+ end
119
+ end
120
+
121
+ def self.gen_height_button_action(spin_widget, parent)
122
+ spin_widget.signal_connect "value-changed" do |widget|
123
+ w, _h = parent.size
124
+ parent.resize(w, widget.value)
125
+ _, h = parent.size
126
+ widget.value = h if widget.value + 1 < h
127
+ end
128
+ end
129
+
130
+ # Hack because when added via glade, the builder fail to load the ui.
131
+ def self.add_source_view_style_chooser(builder, parent)
132
+ box = builder["gen_prefs_box"]
133
+ button = GtkSource::StyleSchemeChooserButton.new
134
+ sm = GtkSource::StyleSchemeManager.default
135
+ button.style_scheme = sm.get_scheme(parent.css_editor_style)
136
+ button.show
137
+ button.signal_connect "style-updated" do |widget|
138
+ parent.css_editor_style = widget.style_scheme.id
139
+ end
140
+ box.pack_start(button, :expand => true, :fill => false)
141
+ end
142
+
143
+ def self.get_source_view_style(builder)
144
+ box = builder["gen_prefs_box"]
145
+ penultimate = box.children.size - 2
146
+ style = box.children[penultimate].style_scheme.id
147
+ { "-TopinambourWindow-css-editor-style" => style }
148
+ end
149
+
150
+ def self.get_entry_value(builder)
151
+ text = builder["shell_entry"].text
152
+ { "-TopinambourWindow-shell" => text }
153
+ end
154
+
155
+ def self.get_switch_values(builder)
156
+ props = {}
157
+ %w(audible_bell allow_bold scroll_on_output
158
+ scroll_on_keystroke rewrap_on_resize mouse_autohide).each do |prop_name|
159
+ switch = builder["#{prop_name}_switch"]
160
+ name = prop_name.tr("_", "-")
161
+ props["-TopinambourTerminal-#{name}"] = switch.active?
162
+ end
163
+ props
164
+ end
165
+
166
+ def self.get_combo_values(builder)
167
+ props = {}
168
+ %w(cursor_shape cursor_blink_mode backspace_binding
169
+ delete_binding).each do |prop_name|
170
+ combobox = builder["#{prop_name}_sel"]
171
+ value = combobox.active_id.gsub(/_id\z/, "")
172
+ name = prop_name.tr("_", "-")
173
+ props["-TopinambourTerminal-#{name}"] = value.to_sym
174
+ end
175
+ props
176
+ end
177
+
178
+ def self.get_spin_values(widget)
179
+ props = {}
180
+ w, h = widget.transient_for.size
181
+ props["-TopinambourWindow-width"] = w
182
+ props["-TopinambourWindow-height"] = h
183
+ props
184
+ end
185
+ end
@@ -1,4 +1,4 @@
1
- # Copyright 2015-2016 Cédric LE MOIGNE, cedlemo@gmx.com
1
+ # Copyright 2015-2016 Cedric LE MOIGNE, cedlemo@gmx.com
2
2
  # This file is part of Topinambour.
3
3
  #
4
4
  # Topinambour is free software: you can redistribute it and/or modify
@@ -0,0 +1,3 @@
1
+ module RgbNames
2
+ COLOR_NAMES = "(snow|ghost white|GhostWhite|white smoke|WhiteSmoke|gainsboro|floral white|FloralWhite|old lace|OldLace|linen|antique white|AntiqueWhite|papaya whip|PapayaWhip|blanched almond|BlanchedAlmond|bisque|peach puff|PeachPuff|navajo white|NavajoWhite|moccasin|cornsilk|ivory|lemon chiffon|LemonChiffon|seashell|honeydew|mint cream|MintCream|azure|alice blue|AliceBlue|lavender|lavender blush|LavenderBlush|misty rose|MistyRose|white|black|dark slate gray|DarkSlateGray|dark slate grey|DarkSlateGrey|dim gray|DimGray|dim grey|DimGrey|slate gray|SlateGray|slate grey|SlateGrey|light slate gray|LightSlateGray|light slate grey|LightSlateGrey|gray|grey|light grey|LightGrey|light gray|LightGray|midnight blue|MidnightBlue|navy|navy blue|NavyBlue|cornflower blue|CornflowerBlue|dark slate blue|DarkSlateBlue|slate blue|SlateBlue|medium slate blue|MediumSlateBlue|light slate blue|LightSlateBlue|medium blue|MediumBlue|royal blue|RoyalBlue|blue|dodger blue|DodgerBlue|deep sky blue|DeepSkyBlue|sky blue|SkyBlue|light sky blue|LightSkyBlue|steel blue|SteelBlue|light steel blue|LightSteelBlue|light blue|LightBlue|powder blue|PowderBlue|pale turquoise|PaleTurquoise|dark turquoise|DarkTurquoise|medium turquoise|MediumTurquoise|turquoise|cyan|light cyan|LightCyan|cadet blue|CadetBlue|medium aquamarine|MediumAquamarine|aquamarine|dark green|DarkGreen|dark olive green|DarkOliveGreen|dark sea green|DarkSeaGreen|sea green|SeaGreen|medium sea green|MediumSeaGreen|light sea green|LightSeaGreen|pale green|PaleGreen|spring green|SpringGreen|lawn green|LawnGreen|green|chartreuse|medium spring green|MediumSpringGreen|green yellow|GreenYellow|lime green|LimeGreen|yellow green|YellowGreen|forest green|ForestGreen|olive drab|OliveDrab|dark khaki|DarkKhaki|khaki|pale goldenrod|PaleGoldenrod|light goldenrod yellow|LightGoldenrodYellow|light yellow|LightYellow|yellow|gold|light goldenrod|LightGoldenrod|goldenrod|dark goldenrod|DarkGoldenrod|rosy brown|RosyBrown|indian red|IndianRed|saddle brown|SaddleBrown|sienna|peru|burlywood|beige|wheat|sandy brown|SandyBrown|tan|chocolate|firebrick|brown|dark salmon|DarkSalmon|salmon|light salmon|LightSalmon|orange|dark orange|DarkOrange|coral|light coral|LightCoral|tomato|orange red|OrangeRed|red|hot pink|HotPink|deep pink|DeepPink|pink|light pink|LightPink|pale violet red|PaleVioletRed|maroon|medium violet red|MediumVioletRed|violet red|VioletRed|magenta|violet|plum|orchid|medium orchid|MediumOrchid|dark orchid|DarkOrchid|dark violet|DarkViolet|blue violet|BlueViolet|purple|medium purple|MediumPurple|thistle|snow1|snow2|snow3|snow4|seashell1|seashell2|seashell3|seashell4|AntiqueWhite1|AntiqueWhite2|AntiqueWhite3|AntiqueWhite4|bisque1|bisque2|bisque3|bisque4|PeachPuff1|PeachPuff2|PeachPuff3|PeachPuff4|NavajoWhite1|NavajoWhite2|NavajoWhite3|NavajoWhite4|LemonChiffon1|LemonChiffon2|LemonChiffon3|LemonChiffon4|cornsilk1|cornsilk2|cornsilk3|cornsilk4|ivory1|ivory2|ivory3|ivory4|honeydew1|honeydew2|honeydew3|honeydew4|LavenderBlush1|LavenderBlush2|LavenderBlush3|LavenderBlush4|MistyRose1|MistyRose2|MistyRose3|MistyRose4|azure1|azure2|azure3|azure4|SlateBlue1|SlateBlue2|SlateBlue3|SlateBlue4|RoyalBlue1|RoyalBlue2|RoyalBlue3|RoyalBlue4|blue1|blue2|blue3|blue4|DodgerBlue1|DodgerBlue2|DodgerBlue3|DodgerBlue4|SteelBlue1|SteelBlue2|SteelBlue3|SteelBlue4|DeepSkyBlue1|DeepSkyBlue2|DeepSkyBlue3|DeepSkyBlue4|SkyBlue1|SkyBlue2|SkyBlue3|SkyBlue4|LightSkyBlue1|LightSkyBlue2|LightSkyBlue3|LightSkyBlue4|SlateGray1|SlateGray2|SlateGray3|SlateGray4|LightSteelBlue1|LightSteelBlue2|LightSteelBlue3|LightSteelBlue4|LightBlue1|LightBlue2|LightBlue3|LightBlue4|LightCyan1|LightCyan2|LightCyan3|LightCyan4|PaleTurquoise1|PaleTurquoise2|PaleTurquoise3|PaleTurquoise4|CadetBlue1|CadetBlue2|CadetBlue3|CadetBlue4|turquoise1|turquoise2|turquoise3|turquoise4|cyan1|cyan2|cyan3|cyan4|DarkSlateGray1|DarkSlateGray2|DarkSlateGray3|DarkSlateGray4|aquamarine1|aquamarine2|aquamarine3|aquamarine4|DarkSeaGreen1|DarkSeaGreen2|DarkSeaGreen3|DarkSeaGreen4|SeaGreen1|SeaGreen2|SeaGreen3|SeaGreen4|PaleGreen1|PaleGreen2|PaleGreen3|PaleGreen4|SpringGreen1|SpringGreen2|SpringGreen3|SpringGreen4|green1|green2|green3|green4|chartreuse1|chartreuse2|chartreuse3|chartreuse4|OliveDrab1|OliveDrab2|OliveDrab3|OliveDrab4|DarkOliveGreen1|DarkOliveGreen2|DarkOliveGreen3|DarkOliveGreen4|khaki1|khaki2|khaki3|khaki4|LightGoldenrod1|LightGoldenrod2|LightGoldenrod3|LightGoldenrod4|LightYellow1|LightYellow2|LightYellow3|LightYellow4|yellow1|yellow2|yellow3|yellow4|gold1|gold2|gold3|gold4|goldenrod1|goldenrod2|goldenrod3|goldenrod4|DarkGoldenrod1|DarkGoldenrod2|DarkGoldenrod3|DarkGoldenrod4|RosyBrown1|RosyBrown2|RosyBrown3|RosyBrown4|IndianRed1|IndianRed2|IndianRed3|IndianRed4|sienna1|sienna2|sienna3|sienna4|burlywood1|burlywood2|burlywood3|burlywood4|wheat1|wheat2|wheat3|wheat4|tan1|tan2|tan3|tan4|chocolate1|chocolate2|chocolate3|chocolate4|firebrick1|firebrick2|firebrick3|firebrick4|brown1|brown2|brown3|brown4|salmon1|salmon2|salmon3|salmon4|LightSalmon1|LightSalmon2|LightSalmon3|LightSalmon4|orange1|orange2|orange3|orange4|DarkOrange1|DarkOrange2|DarkOrange3|DarkOrange4|coral1|coral2|coral3|coral4|tomato1|tomato2|tomato3|tomato4|OrangeRed1|OrangeRed2|OrangeRed3|OrangeRed4|red1|red2|red3|red4|DebianRed|DeepPink1|DeepPink2|DeepPink3|DeepPink4|HotPink1|HotPink2|HotPink3|HotPink4|pink1|pink2|pink3|pink4|LightPink1|LightPink2|LightPink3|LightPink4|PaleVioletRed1|PaleVioletRed2|PaleVioletRed3|PaleVioletRed4|maroon1|maroon2|maroon3|maroon4|VioletRed1|VioletRed2|VioletRed3|VioletRed4|magenta1|magenta2|magenta3|magenta4|orchid1|orchid2|orchid3|orchid4|plum1|plum2|plum3|plum4|MediumOrchid1|MediumOrchid2|MediumOrchid3|MediumOrchid4|DarkOrchid1|DarkOrchid2|DarkOrchid3|DarkOrchid4|purple1|purple2|purple3|purple4|MediumPurple1|MediumPurple2|MediumPurple3|MediumPurple4|thistle1|thistle2|thistle3|thistle4|gray0|grey0|gray1|grey1|gray2|grey2|gray3|grey3|gray4|grey4|gray5|grey5|gray6|grey6|gray7|grey7|gray8|grey8|gray9|grey9|gray10|grey10|gray11|grey11|gray12|grey12|gray13|grey13|gray14|grey14|gray15|grey15|gray16|grey16|gray17|grey17|gray18|grey18|gray19|grey19|gray20|grey20|gray21|grey21|gray22|grey22|gray23|grey23|gray24|grey24|gray25|grey25|gray26|grey26|gray27|grey27|gray28|grey28|gray29|grey29|gray30|grey30|gray31|grey31|gray32|grey32|gray33|grey33|gray34|grey34|gray35|grey35|gray36|grey36|gray37|grey37|gray38|grey38|gray39|grey39|gray40|grey40|gray41|grey41|gray42|grey42|gray43|grey43|gray44|grey44|gray45|grey45|gray46|grey46|gray47|grey47|gray48|grey48|gray49|grey49|gray50|grey50|gray51|grey51|gray52|grey52|gray53|grey53|gray54|grey54|gray55|grey55|gray56|grey56|gray57|grey57|gray58|grey58|gray59|grey59|gray60|grey60|gray61|grey61|gray62|grey62|gray63|grey63|gray64|grey64|gray65|grey65|gray66|grey66|gray67|grey67|gray68|grey68|gray69|grey69|gray70|grey70|gray71|grey71|gray72|grey72|gray73|grey73|gray74|grey74|gray75|grey75|gray76|grey76|gray77|grey77|gray78|grey78|gray79|grey79|gray80|grey80|gray81|grey81|gray82|grey82|gray83|grey83|gray84|grey84|gray85|grey85|gray86|grey86|gray87|grey87|gray88|grey88|gray89|grey89|gray90|grey90|gray91|grey91|gray92|grey92|gray93|grey93|gray94|grey94|gray95|grey95|gray96|grey96|gray97|grey97|gray98|grey98|gray99|grey99|gray100|grey100|dark grey|DarkGrey|dark gray|DarkGray|dark blue|DarkBlue|dark cyan|DarkCyan|dark magenta|DarkMagenta|dark red|DarkRed|light green|LightGreen)"
3
+ end
data/lib/searchbar.rb ADDED
@@ -0,0 +1,54 @@
1
+ # Copyright 2016 Cedric LE MOIGNE, cedlemo@gmx.com
2
+ # This file is part of Topinambour.
3
+ #
4
+ # Topinambour is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # any later version.
8
+ #
9
+ # Topinambour is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with Topinambour. If not, see <http://www.gnu.org/licenses/>.
16
+
17
+ class TopinambourSearchBar < Gtk::SearchBar
18
+ def initialize(window)
19
+ super()
20
+
21
+ generate_search_entry(window)
22
+ set_halign(:center)
23
+ set_valign(:start)
24
+ set_hexpand(false)
25
+ set_vexpand(true)
26
+ connect_entry(@entry)
27
+ set_show_close_button = true
28
+ add(@entry)
29
+ end
30
+
31
+ def generate_search_entry(window)
32
+ @entry = Gtk::SearchEntry.new
33
+ term = window.notebook.current
34
+ @entry.signal_connect "next-match" do |entry|
35
+ puts "next-match"
36
+ term.search_find_next if @regex
37
+ end
38
+
39
+ @entry.signal_connect "previous-match" do |entry|
40
+ puts "prev match"
41
+ term.search_find_previous if @regex
42
+ end
43
+
44
+ @entry.signal_connect "search-changed" do |entry|
45
+ puts "search changed"
46
+ pattern = entry.buffer.text
47
+ if pattern != ""
48
+ @regex = GLib::Regex.new(pattern)
49
+ term.search_set_gregex(@regex, @regex.match_flags)
50
+ term.search_find_next
51
+ end
52
+ end
53
+ end
54
+ end
data/lib/shortcuts.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright 2016 Cédric LE MOIGNE, cedlemo@gmx.com
1
+ # Copyright 2016 Cedric LE MOIGNE, cedlemo@gmx.com
2
2
  # This file is part of Topinambour.
3
3
  #
4
4
  # Topinambour is free software: you can redistribute it and/or modify
@@ -21,8 +21,9 @@ module TopinambourShortcuts
21
21
  (Gdk::ModifierType::CONTROL_MASK | Gdk::ModifierType::SHIFT_MASK)
22
22
  end
23
23
 
24
- def self.handle_simple(keyval, window)
25
- case keyval
24
+ def self.handle_simple(event, window)
25
+ overlay_mode = window.in_overlay_mode?
26
+ case event.keyval
26
27
  when Gdk::Keyval::KEY_Escape # escape from overlay mode
27
28
  if window.in_overlay_mode?
28
29
  window.exit_overlay_mode
@@ -32,8 +33,8 @@ module TopinambourShortcuts
32
33
  end
33
34
  end
34
35
 
35
- def self.handle_ctrl_shift(keyval, window)
36
- case keyval
36
+ def self.handle_ctrl_shift(event, window)
37
+ case event.keyval
37
38
  when Gdk::Keyval::KEY_W # close the current tab
38
39
  window.close_current_tab
39
40
  true
@@ -61,16 +62,34 @@ module TopinambourShortcuts
61
62
  when Gdk::Keyval::KEY_E
62
63
  window.show_css_editor
63
64
  true
65
+ when Gdk::Keyval::KEY_slash
66
+ window.show_searchbar
67
+ true
68
+ when Gdk::Keyval::KEY_Up
69
+ window.toggle_shrink
70
+ true
64
71
  end
65
72
  end
66
73
 
67
74
  def self.handle_key_press(window, event)
68
75
  keyval = event.keyval
69
- #puts "#{Gdk::Keyval.to_name(keyval)} = #{keyval}"
70
76
  if ctrl_shift?(event)
71
- handle_ctrl_shift(keyval, window)
77
+ handle_ctrl_shift(event, window)
72
78
  else
73
- handle_simple(keyval, window)
79
+ handle_simple(event, window)
80
+ end
81
+ end
82
+
83
+ def self.handle_scroll(window, event)
84
+ if ctrl_shift?(event)
85
+ case event.direction
86
+ when Gdk::ScrollDirection::UP
87
+ window.opacity = window.opacity + 0.05
88
+ true
89
+ when Gdk::ScrollDirection::DOWN
90
+ window.opacity = window.opacity - 0.05
91
+ true
92
+ end
74
93
  end
75
94
  end
76
95
  end
@@ -1,4 +1,4 @@
1
- # Copyright 2016 Cédric LE MOIGNE, cedlemo@gmx.com
1
+ # Copyright 2016 Cedric LE MOIGNE, cedlemo@gmx.com
2
2
  # This file is part of Topinambour.
3
3
  #
4
4
  # Topinambour is free software: you can redistribute it and/or modify
@@ -24,6 +24,15 @@ module TopinambourStyleProperties
24
24
  GLib::Param::WRITABLE)
25
25
  end
26
26
 
27
+ def generate_boolean_rw_property(name, args)
28
+ GLib::Param::Boolean.new(name.downcase,
29
+ name.capitalize,
30
+ name.upcase,
31
+ args,
32
+ GLib::Param::READABLE |
33
+ GLib::Param::WRITABLE)
34
+ end
35
+
27
36
  def generate_int_rw_property(name, args)
28
37
  GLib::Param::Int.new(name.downcase,
29
38
  name.capitalize,
@@ -33,6 +42,15 @@ module TopinambourStyleProperties
33
42
  GLib::Param::WRITABLE)
34
43
  end
35
44
 
45
+ def generate_enum_rw_property(name, args)
46
+ GLib::Param::Enum.new(name.downcase,
47
+ name.capitalize,
48
+ name.upcase,
49
+ *args,
50
+ GLib::Param::READABLE |
51
+ GLib::Param::WRITABLE)
52
+ end
53
+
36
54
  def generate_boxed_rw_property(name, args)
37
55
  GLib::Param::Boxed.new(name.downcase,
38
56
  name.capitalize,
@@ -62,42 +80,9 @@ TERMINAL_COLOR_NAMES = [:foreground, :background, :black, :red, :green, :yellow,
62
80
  ]
63
81
  DEFAULT_TERMINAL_COLORS = %w(#aeafad #323232 #000000 #b9214f #A6E22E #ff9800
64
82
  #3399ff #8e33ff #06a2dc #B0B0B0 #5D5D5D #ff5c8d
65
- #CDEE69 #ffff00 #9CD9F0 #FBB1F9 #77DFD8 #F7F7F7
66
- )
83
+ #CDEE69 #ffff00 #9CD9F0 #FBB1F9 #77DFD8 #F7F7F7)
67
84
  DEFAULT_TERMINAL_FONT = "Monospace 11"
68
85
 
69
- # boolean :
70
- #
71
- # audible_bell
72
- # allow_bold
73
- # scroll_on_output
74
- # scroll_on_keystroke
75
- # rewrap_on_resize
76
- # mouse_autohide
77
- #
78
- # VteCursorShape :
79
- # cursor_shape
80
- # VTE_CURSOR_SHAPE_BLOCK Draw a block cursor. This is the default.
81
- # VTE_CURSOR_SHAPE_IBEAM Draw a vertical bar on the left side of character.
82
- # This is similar to the default cursor for other GTK+ widgets.
83
- # VTE_CURSOR_SHAPE_UNDERLINE Draw a horizontal bar below the character.
84
- #
85
- # VteCursorBlinkMode
86
- # cursor_blink_mode
87
- # VTE_CURSOR_BLINK_SYSTEM Follow GTK+ settings for cursor blinking.
88
- # VTE_CURSOR_BLINK_ON Cursor blinks.
89
- # VTE_CURSOR_BLINK_OFF Cursor does not blink.
90
- #
91
- # VteEraseBinding
92
- # backspace_binding
93
- # delete_binding
94
- # VTE_ERASE_AUTO For backspace, attempt to determine the right value from the
95
- # terminal's IO settings. For delete, use the control sequence.
96
- # VTE_ERASE_ASCII_BACKSPACE Send an ASCII backspace character (0x08).
97
- # VTE_ERASE_ASCII_DELETE Send an ASCII delete character (0x7F).
98
- # VTE_ERASE_DELETE_SEQUENCE Send the "@7 " control sequence.
99
- # VTE_ERASE_TTY Send terminal's "erase" setting.
100
-
101
86
  class TopinambourTerminal < Vte::Terminal
102
87
  extend TopinambourStyleProperties
103
88
  type_register
@@ -107,9 +92,31 @@ class TopinambourTerminal < Vte::Terminal
107
92
  name,
108
93
  GLib::Type["GdkRGBA"])
109
94
  end
110
- install_style("boxed",
111
- "font",
95
+ install_style("boxed", "font",
112
96
  GLib::Type["PangoFontDescription"])
97
+ install_style("boolean", "audible-bell", false)
98
+ install_style("boolean", "allow-bold", true)
99
+ install_style("boolean", "scroll-on-output", true)
100
+ install_style("boolean", "scroll-on-keystroke", true)
101
+ install_style("boolean", "rewrap-on-resize", true)
102
+ install_style("boolean", "mouse-autohide", true)
103
+ install_style("enum", "cursor-shape", [GLib::Type["VteCursorShape"],
104
+ Vte::CursorShape::BLOCK])
105
+ install_style("enum", "cursor-blink-mode", [GLib::Type["VteCursorBlinkMode"],
106
+ Vte::CursorBlinkMode::SYSTEM])
107
+ install_style("enum", "backspace-binding", [GLib::Type["VteEraseBinding"],
108
+ Vte::EraseBinding::AUTO])
109
+ install_style("enum", "delete-binding", [GLib::Type["VteEraseBinding"],
110
+ Vte::EraseBinding::AUTO])
111
+ def load_properties
112
+ %w(audible_bell allow_bold scroll_on_output scroll_on_keystroke
113
+ rewrap_on_resize mouse_autohide).each do |prop|
114
+ send("#{prop}=", style_get_property(prop.gsub(/_/,"-")))
115
+ end
116
+ %w(cursor_shape cursor_blink_mode backspace_binding delete_binding).each do |prop|
117
+ send("#{prop}=", style_get_property(prop.gsub(/_/,"-")))
118
+ end
119
+ end
113
120
  end
114
121
 
115
122
  class TopinambourWindow < Gtk::ApplicationWindow
@@ -119,4 +126,8 @@ class TopinambourWindow < Gtk::ApplicationWindow
119
126
  install_style("int", "width", [-1, 2000, 1000])
120
127
  install_style("int", "height", [-1, 2000, 500])
121
128
  install_style("string", "css-editor-style", "classic")
129
+
130
+ def load_properties
131
+
132
+ end
122
133
  end
data/lib/terminal.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright 2015-2016 Cédric LE MOIGNE, cedlemo@gmx.com
1
+ # Copyright 2015-2016 Cedric LE MOIGNE, cedlemo@gmx.com
2
2
  # This file is part of Topinambour.
3
3
  #
4
4
  # Topinambour is free software: you can redistribute it and/or modify
@@ -104,9 +104,11 @@ class TopinambourTerminal
104
104
  def configure
105
105
  set_rewrap_on_resize(true)
106
106
  set_scrollback_lines(-1)
107
+ search_set_wrap_around(true)
107
108
  @colors = css_colors
108
109
  set_font(css_font)
109
110
  apply_colors
111
+ load_properties
110
112
  add_matches
111
113
  end
112
114