topinambour 1.0.16 → 2.0.0

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.
@@ -1,4 +1,4 @@
1
- # Copyright 2015-2017 Cedric LE MOIGNE, cedlemo@gmx.com
1
+ # Copyright 2015-2018 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
@@ -38,7 +38,7 @@ class TopinambourColorSelector < Gtk::Box
38
38
  show_all
39
39
  set_halign(:center)
40
40
  set_valign(:end)
41
- set_name("color_selector")
41
+ set_name("topinambour-color-selector")
42
42
  end
43
43
 
44
44
  private
@@ -64,8 +64,8 @@ class TopinambourColorSelector < Gtk::Box
64
64
  def apply_new_properties
65
65
  colors_strings = @colors.map { |c| c.to_s }
66
66
  @window.application.settings["colorscheme"] = colors_strings
67
- @window.notebook.send_to_all_terminals(:colors, nil)
68
- @window.notebook.send_to_all_terminals(:load_settings, nil)
67
+ @window.terminal.colors
68
+ @window.terminal.load_settings
69
69
  end
70
70
 
71
71
  def generate_save_button
@@ -81,6 +81,7 @@ class TopinambourColorSelector < Gtk::Box
81
81
  TERMINAL_COLOR_NAMES.each_with_index do |name, i|
82
82
  color_sel = Gtk::ColorButton.new(@default_colors[i])
83
83
  color_sel.title = name.to_s
84
+ color_sel.name = "topinambour-button-#{name}"
84
85
  color_sel.tooltip_text = name.to_s
85
86
  color_sel.signal_connect "color-set" do
86
87
  @colors[i] = color_sel.rgba
@@ -91,6 +92,6 @@ class TopinambourColorSelector < Gtk::Box
91
92
  end
92
93
 
93
94
  def apply_new_colors
94
- @window.notebook.current.term.colors = @colors
95
+ @window.terminal.colors = @colors
95
96
  end
96
97
  end
data/lib/font_selector.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright 2015-2017 Cedric LE MOIGNE, cedlemo@gmx.com
1
+ # Copyright 2015-2018 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
@@ -42,7 +42,7 @@ class TopinambourFontSelector < Gtk::Box
42
42
  toplevel.exit_overlay_mode
43
43
  end
44
44
  pack_start(save_button, :expand => false, :fill => false, :padding => 0)
45
- set_name("font_selector")
45
+ set_name("topinambour-font-selector")
46
46
  show_all
47
47
  set_halign(:center)
48
48
  set_valign(:end)
data/lib/preferences.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright 2016-2017 Cedric LE MOIGNE, cedlemo@gmx.com
1
+ # Copyright 2016-2018 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/shortcuts.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright 2016-2017 Cedric LE MOIGNE, cedlemo@gmx.com
1
+ # Copyright 2016-2018 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
@@ -26,7 +26,7 @@ module TopinambourShortcuts
26
26
  when Gdk::Keyval::KEY_Escape # escape from overlay mode
27
27
  if window.in_overlay_mode?
28
28
  window.exit_overlay_mode
29
- window.notebook.current.term.grab_focus
29
+ window.terminal.grab_focus
30
30
  true
31
31
  end
32
32
  end
@@ -40,27 +40,12 @@ module TopinambourShortcuts
40
40
  when Gdk::Keyval::KEY_Q # Quit
41
41
  window.quit_gracefully
42
42
  true
43
- when Gdk::Keyval::KEY_T # New tab
44
- window.add_terminal
45
- true
46
43
  when Gdk::Keyval::KEY_C
47
44
  window.show_color_selector
48
45
  true
49
46
  when Gdk::Keyval::KEY_F
50
47
  window.show_font_selector
51
48
  true
52
- when Gdk::Keyval::KEY_Left # previous tab
53
- window.show_prev_tab
54
- true
55
- when Gdk::Keyval::KEY_Right # next tab
56
- window.show_next_tab
57
- true
58
- when Gdk::Keyval::KEY_O
59
- window.show_terminal_chooser
60
- true
61
- when Gdk::Keyval::KEY_slash
62
- window.show_searchbar
63
- true
64
49
  when Gdk::Keyval::KEY_Page_Up
65
50
  window.opacity = window.opacity + 0.05
66
51
  true
data/lib/terminal.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright 2015-2017 Cedric LE MOIGNE, cedlemo@gmx.com
1
+ # Copyright 2015-2018 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
@@ -17,44 +17,35 @@
17
17
  ## The main full tab Gtk::Box + Vte::Terminal + Gtk::Scrollbar
18
18
  #
19
19
 
20
- class TopinambourTabTerm < Gtk::Box
20
+ class TopinambourTermBox < Gtk::Box
21
21
  attr_reader :term
22
22
  def initialize(command_string, working_dir = nil)
23
23
  super(:horizontal, 0)
24
- set_name("topinambour-tab-term")
24
+ set_name("topinambour-term-box")
25
25
  @term = TopinambourTerminal.new(command_string, working_dir)
26
26
  @scrollbar = Gtk::Scrollbar.new(:vertical, @term.vadjustment)
27
27
  @scrollbar.name = "topinambour-scrollbar"
28
28
  pack_start(@term, :expand => true, :fill => true, :padding => 0)
29
29
  pack_start(@scrollbar)
30
+ show_all
30
31
  end
31
32
  end
33
+
32
34
  ##
33
35
  # The default vte terminal customized
34
36
  class TopinambourTerminal < Vte::Terminal
35
37
  attr_reader :pid, :menu, :regexes, :last_match
36
- attr_accessor :preview, :custom_title
37
38
 
38
39
  ##
39
40
  # Create a new TopinambourTerminal instance that runs command_string
40
41
  def initialize(command_string, working_dir = nil)
41
42
  super()
42
-
43
+ set_name("topinambour-terminal")
43
44
  command_array = parse_command(command_string)
44
45
  rescued_spawn(command_array, working_dir)
45
46
 
46
47
  signal_connect "child-exited" do |widget|
47
- tabterm = widget.parent
48
- notebook = tabterm.parent
49
- current_page = notebook.page_num(tabterm)
50
- notebook.remove_page(current_page)
51
- @application.quit unless notebook.n_pages >= 1
52
- end
53
-
54
- signal_connect "window-title-changed" do |widget|
55
- tabterm = widget.parent
56
- notebook = tabterm.parent
57
- when_terminal_title_change if notebook && notebook.current.term == self
48
+ toplevel.application.quit
58
49
  end
59
50
 
60
51
  add_popup_menu
@@ -76,13 +67,13 @@ class TopinambourTerminal < Vte::Terminal
76
67
  end
77
68
 
78
69
  def colors
79
- colors_strings = application.settings["colorscheme"]
70
+ colors_strings = toplevel.application.settings["colorscheme"]
80
71
  @colors = colors_strings.map { |c| Gdk::RGBA.parse(c) }
81
72
  @colors
82
73
  end
83
74
 
84
75
  def font
85
- font_str = application.settings["font"]
76
+ font_str = toplevel.application.settings["font"]
86
77
  @font = Pango::FontDescription.new(font_str)
87
78
  end
88
79
 
@@ -91,17 +82,12 @@ class TopinambourTerminal < Vte::Terminal
91
82
  end
92
83
 
93
84
  def font=(font_str)
94
- application.settings["font"] = font_str
85
+ toplevel.application.settings["font"] = font_str
95
86
  font = Pango::FontDescription.new(font_str)
96
87
  set_font(font)
97
88
  @font = font
98
89
  end
99
90
 
100
- def application
101
- @application = self.parent.toplevel.application unless @application
102
- @application
103
- end
104
-
105
91
  private
106
92
 
107
93
  def parse_command(command_string)
@@ -200,10 +186,6 @@ class TopinambourTerminal < Vte::Terminal
200
186
  end
201
187
  end
202
188
 
203
- def when_terminal_title_change
204
- parent.toplevel.current_label.text = terminal_title
205
- end
206
-
207
189
  def launch_default_for_regex_match(match, regex_type)
208
190
  Gio::AppInfo.launch_default_for_uri(match)
209
191
  rescue => e
@@ -1,4 +1,4 @@
1
- # Copyright 2016 Cedric LE MOIGNE, cedlemo@gmx.com
1
+ # Copyright 2016-2017 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
@@ -90,12 +90,17 @@ module PortRegexes
90
90
  end
91
91
 
92
92
  module PathRegexes
93
+ # Omit the parentheses
93
94
  PATHCHARS_CLASS = "[-[:alnum:]\\Q_$.+!*,:;@&=?/~#|%\\E]"
94
- # Chars not to end a URL */
95
- PATHNONTERM_CLASS = "[\\Q.!,?\\E]"
96
- # Lookbehind at the end, so that the last character (if we matched a character at all) is not from PATHTERM_CLASS */
97
- URLPATH = "(?x: /#{PATHCHARS_CLASS}* (?<! #{PATHNONTERM_CLASS} ) )?"
98
- VOIP_PATH = "(?x: [;?]#{PATHCHARS_CLASS}* (?<! #{PATHNONTERM_CLASS} ) )?"
95
+ # Chars to end a URL
96
+ PATHTERM_CLASS = "[-[:alnum:]\\Q_$+*:@&=/~#|%\\E]"
97
+ # Recursive definition of PATH that allows parentheses and square brackets only if balanced, see bug 763980.
98
+ PATH_INNER_DEF = "(?(DEFINE)(?<PATH_INNER>(?x: (?: #{PATHCHARS_CLASS}* (?: \\( (?&PATH_INNER) \\) | \\[ (?&PATH_INNER) \\] ) )* #{PATHCHARS_CLASS}* )))"
99
+ # "(?(DEFINE)(?<PATH_INNER>(?x: (?: " PATHCHARS_CLASS"* \\( (?&PATH_INNER) \\) )* " PATHCHARS_CLASS "* )))"
100
+ # Same as above, but the last character (if exists and is not a parenthesis) must be from PATHTERM_CLASS.
101
+ PATH_DEF = "(?(DEFINE)(?<PATH>(?x: (?: #{PATHCHARS_CLASS}* (?: \\( (?&PATH_INNER) \\) | \\[ (?&PATH_INNER) \\] ) )* (?: #{PATHCHARS_CLASS}* #{PATHTERM_CLASS} )? )))"
102
+ URLPATH = "(?x: /(?&PATH) )?"
103
+ VOIP_PATH = "(?x: [;?](?&PATH) )?"
99
104
  end
100
105
 
101
106
  module ColorRegexes
@@ -121,10 +126,10 @@ module TopinambourRegex
121
126
  include PathRegexes
122
127
 
123
128
  # Now let's put these fragments together */
124
- DEFS = IP_DEF
129
+ DEFS = "#{IP_DEF}#{PATH_INNER_DEF}#{PATH_DEF}"
125
130
  REGEX_URL_AS_IS = "#{DEFS}#{SCHEME}://#{USERPASS}#{URL_HOST}#{PORT}#{URLPATH}"
126
131
  # TODO: also support file:/etc/passwd */
127
- REGEX_URL_FILE = "#{DEFS}(?ix: file:/ (?: / (?: #{HOSTNAME1} )? / )? (?! / ) )(?x: #{PATHCHARS_CLASS}+ (?<! #{PATHNONTERM_CLASS} ) )?"
132
+ REGEX_URL_FILE = "#{DEFS}(?ix: file:/ (?: / (?: #{HOSTNAME1} )? / )? (?! / ) )(?&PATH)"
128
133
  # Lookbehind so that we don't catch "abc.www.foo.bar", bug 739757.
129
134
  # Lookahead for www/ftp for convenience (so that we can reuse HOSTNAME1). */
130
135
  REGEX_URL_HTTP = "#{DEFS}(?<!(?:#{HOSTNAMESEGMENTCHARS_CLASS}|[.]))(?=(?i:www|ftp))#{HOSTNAME1}#{PORT}#{URLPATH}"
data/lib/window.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright 2015-2017 Cedric LE MOIGNE, cedlemo@gmx.com
1
+ # Copyright 2015-2018 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
@@ -15,7 +15,7 @@
15
15
  # along with Topinambour. If not, see <http://www.gnu.org/licenses/>.
16
16
 
17
17
  class TopinambourWindow < Gtk::ApplicationWindow
18
- attr_reader :notebook, :bar, :overlay, :current_label, :current_tab
18
+ attr_reader :bar, :overlay, :terminal
19
19
  def initialize(application)
20
20
  super(application)
21
21
  set_icon_name("utilities-terminal-symbolic")
@@ -23,7 +23,8 @@ class TopinambourWindow < Gtk::ApplicationWindow
23
23
  load_settings
24
24
  set_position(:center)
25
25
  create_header_bar
26
- create_containers
26
+ @overlay = Gtk::Overlay.new
27
+ add(@overlay)
27
28
  show_all
28
29
  signal_connect "key-press-event" do |widget, event|
29
30
  TopinambourShortcuts.handle_key_press(widget, event)
@@ -33,24 +34,13 @@ class TopinambourWindow < Gtk::ApplicationWindow
33
34
  def add_terminal(cmd = nil)
34
35
  cmd = cmd || application.settings["default-shell"]
35
36
 
36
- exit_overlay_mode
37
- working_dir = nil
38
- working_dir = @notebook.current.term.pid_dir if @notebook.current
39
- terminal = TopinambourTabTerm.new(cmd, working_dir)
40
- if terminal.term.pid
41
- terminal.show_all
42
-
43
- @notebook.append_page(terminal)
44
- terminal.term.load_settings
45
- @notebook.set_tab_reorderable(terminal, true)
46
- @notebook.set_page(@notebook.n_pages - 1)
47
- @notebook.current.term.grab_focus
48
- end
37
+ terminal = TopinambourTermBox.new(cmd)
38
+ @overlay.add(terminal)
39
+ @terminal = terminal.term
40
+ terminal.term.load_settings
49
41
  end
50
42
 
51
43
  def quit_gracefully
52
- exit_overlay_mode
53
- @notebook.remove_all_pages
54
44
  application.quit
55
45
  end
56
46
 
@@ -58,26 +48,10 @@ class TopinambourWindow < Gtk::ApplicationWindow
58
48
  toggle_overlay(TopinambourColorSelector)
59
49
  end
60
50
 
61
- def show_prev_tab
62
- exit_overlay_mode
63
- @notebook.cycle_prev_page
64
- @notebook.current.term.grab_focus
65
- end
66
-
67
- def show_next_tab
68
- exit_overlay_mode
69
- @notebook.cycle_next_page
70
- @notebook.current.term.grab_focus
71
- end
72
-
73
51
  def show_font_selector
74
52
  toggle_overlay(TopinambourFontSelector)
75
53
  end
76
54
 
77
- def show_terminal_chooser
78
- toggle_overlay(TopinambourTermChooser)
79
- end
80
-
81
55
  def exit_overlay_mode
82
56
  @overlay.children[1].destroy if in_overlay_mode?
83
57
  end
@@ -90,27 +64,16 @@ class TopinambourWindow < Gtk::ApplicationWindow
90
64
  "license" => "This program is licenced under the licence GPL-3.0 and later.",
91
65
  "logo_icon_name" => "utilities-terminal-symbolic",
92
66
  "program_name" => "Topinambour",
93
- "version" => "1.0.16",
67
+ "version" => "2.0.0",
94
68
  "website" => "https://github.com/cedlemo/topinambour",
95
69
  "website_label" => "Topinambour github repository"
96
70
  )
97
71
  end
98
72
 
99
- def close_current_tab
100
- exit_overlay_mode
101
- @notebook.remove_current_page
102
- end
103
-
104
73
  def in_overlay_mode?
105
74
  @overlay.children.size > 1 ? true : false
106
75
  end
107
76
 
108
- def show_searchbar
109
- toggle_overlay(TopinambourSearchBar)
110
- overlayed_widget = @overlay.children[1]
111
- overlayed_widget.search_mode = true if overlayed_widget
112
- end
113
-
114
77
  def toggle_shrink
115
78
  w, h = size
116
79
  if @shrink_saved_height
@@ -122,14 +85,6 @@ class TopinambourWindow < Gtk::ApplicationWindow
122
85
  end
123
86
  end
124
87
 
125
- def show_shortcuts
126
- resource_file = "/com/github/cedlemo/topinambour/shortcuts.ui"
127
- builder = Gtk::Builder.new(:resource => resource_file)
128
- shortcuts_win = builder["shortcuts-window"]
129
- shortcuts_win.transient_for = self
130
- shortcuts_win.show
131
- end
132
-
133
88
  private
134
89
 
135
90
  def load_settings
@@ -143,64 +98,11 @@ class TopinambourWindow < Gtk::ApplicationWindow
143
98
  @overlay.set_overlay_pass_through(widget, false)
144
99
  end
145
100
 
146
- def create_containers
147
- @notebook = TopinambourNotebook.new
148
- @overlay = Gtk::Overlay.new
149
- @overlay.add(@notebook)
150
- add(@overlay)
151
- end
152
-
153
101
  def create_header_bar
154
- resource_file = "/com/github/cedlemo/topinambour/headerbar.ui"
155
- builder = Gtk::Builder.new(:resource => resource_file)
156
- headerbar = builder["headerbar"]
102
+ headerbar = Gtk::HeaderBar.new
157
103
  headerbar.name = "topinambour-headerbar"
104
+ headerbar.show_close_button = true
158
105
  set_titlebar(headerbar)
159
- # Text is modified when notebook switch tabs or
160
- # Vte::Terminal command change and if it is the current Vte.
161
- @current_label = builder["current_label"]
162
- current_label_signals
163
- # Value is changed when notebook switch tabs or notebook add tab.
164
- @current_tab = builder["current_tab"]
165
- headerbar.remove(@current_label)
166
- headerbar.custom_title = @current_label
167
- next_prev_new_signals(builder)
168
- overview_signal(builder)
169
- main_menu_signal(builder)
170
- end
171
-
172
- def current_label_signals
173
- @current_label.signal_connect "activate" do |entry|
174
- @notebook.current.term.custom_title = entry.text
175
- @notebook.current.term.grab_focus
176
- end
177
-
178
- @current_label.signal_connect "icon-release" do |entry, position|
179
- if position == :secondary
180
- @notebook.current.term.custom_title = nil
181
- entry.text = @notebook.current.term.window_title
182
- end
183
- end
184
- end
185
-
186
- def next_prev_new_signals(builder)
187
- builder["prev_button"].signal_connect "clicked" do
188
- show_prev_tab
189
- end
190
-
191
- builder["next_button"].signal_connect "clicked" do
192
- show_next_tab
193
- end
194
-
195
- builder["new_term"].signal_connect "clicked" do
196
- add_terminal
197
- end
198
- end
199
-
200
- def overview_signal(builder)
201
- builder["term_overv_button"].signal_connect "clicked" do
202
- show_terminal_chooser
203
- end
204
106
  end
205
107
 
206
108
  def main_menu_signal(builder)
@@ -231,7 +133,7 @@ class TopinambourWindow < Gtk::ApplicationWindow
231
133
  def toggle_overlay(klass)
232
134
  if in_overlay_mode? && @overlay.children[1].class == klass
233
135
  exit_overlay_mode
234
- @notebook.current.term.grab_focus
136
+ @terminal.grab_focus
235
137
  else
236
138
  exit_overlay_mode
237
139
  add_overlay(klass.new(self))
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: topinambour
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.16
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cedric LE MOIGNE
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-20 00:00:00.000000000 Z
11
+ date: 2018-01-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: vte3
@@ -58,13 +58,10 @@ files:
58
58
  - lib/application.rb
59
59
  - lib/color_selector.rb
60
60
  - lib/font_selector.rb
61
- - lib/notebook.rb
62
61
  - lib/preferences.rb
63
62
  - lib/rgb_names_regexes.rb
64
- - lib/searchbar.rb
65
63
  - lib/shortcuts.rb
66
64
  - lib/terminal.rb
67
- - lib/terminal_chooser.rb
68
65
  - lib/terminal_regex.rb
69
66
  - lib/window.rb
70
67
  homepage: https://github.com/cedlemo/topinambour
@@ -87,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
84
  version: '0'
88
85
  requirements: []
89
86
  rubyforge_project:
90
- rubygems_version: 2.6.14
87
+ rubygems_version: 2.7.3
91
88
  signing_key:
92
89
  specification_version: 4
93
90
  summary: Ruby-gnome2 Terminal emulator