glimmer-cs-gladiator 0.2.0 → 0.3.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.
- checksums.yaml +4 -4
- data/README.md +67 -20
- data/VERSION +1 -1
- data/lib/glimmer-cs-gladiator.rb +24 -0
- data/lib/models/glimmer/gladiator/dir.rb +59 -24
- data/lib/models/glimmer/gladiator/file.rb +18 -9
- data/lib/views/glimmer/gladiator.rb +250 -108
- data/lib/views/glimmer/gladiator/text_editor.rb +15 -1
- metadata +13 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1111b445263923138023d8a6944c2e9e97acabee157bf51b3ebe6b198a082f1d
|
4
|
+
data.tar.gz: 9eb85280093b99e302eccfe2d5ca63728d52cf76c823917a5317fc6b0c2ad771
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3439fc60d40194cdf87431cdd886c43c16e75e0855040acd84017127b3f2b3f1d6a89b2b52bf9f69b39c7fc82defc87b499a14cdb1c19608f1765ebe6b12209
|
7
|
+
data.tar.gz: 4235750d7d134285f32e1b7961041232bfe8f31f9260836fbd067f1cc6fb81752d79f61bc5171bfe6da39d59fe6dd6ff96d65d87e88630156dc46f8ca5e8d699
|
data/README.md
CHANGED
@@ -1,15 +1,18 @@
|
|
1
|
-
#
|
1
|
+
# <img src='https://raw.githubusercontent.com/AndyObtiva/glimmer-cs-gladiator/master/images/glimmer-cs-gladiator-logo.svg' height=85 /> Gladiator 0.3.0 - [Ugliest Text Editor Ever](https://www.reddit.com/r/ruby/comments/hgve8k/gladiator_glimmer_editor_ugliest_text_editor_ever/)
|
2
|
+
## [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=40 /> Glimmer Custom Shell](https://github.com/AndyObtiva/glimmer-dsl-swt#custom-shell-gem)
|
2
3
|
[](http://badge.fury.io/rb/glimmer-cs-gladiator)
|
3
4
|
|
4
5
|

|
5
6
|
|
6
|
-
Gladiator (short for Glimmer Editor) is a Glimmer sample project under on-going development.
|
7
|
-
It is not intended to be a full-fledged editor by any means, yet mostly a fun educational exercise in using Glimmer
|
8
|
-
Gladiator is also a personal tool for shaping an editor exactly the way I like.
|
9
|
-
I leave building truly professional text editors to software tooling experts who would hopefully use Glimmer one day.
|
7
|
+
Gladiator (short for Glimmer Editor) is a [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) sample project under on-going development that demonstrates how to build a text editor in [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) (JRuby Desktop Development GUI Library).
|
8
|
+
It is not intended to be a full-fledged editor by any means, yet mostly a fun educational exercise in using [Glimmer](https://github.com/AndyObtiva/glimmer).
|
9
|
+
Gladiator is also a personal tool for shaping an editor exactly the way I like, with all the keyboard shortcuts I prefer.
|
10
|
+
I leave building truly professional text editors to software tooling experts who would hopefully use [Glimmer](https://github.com/AndyObtiva/glimmer) one day. Otherwise, I have been happily using Gladiator to develop all my [open-source projects](https://github.com/AndyObtiva) since May of 2020.
|
10
11
|
|
11
|
-
|
12
|
-
|
12
|
+
## Features
|
13
|
+
|
14
|
+
Gladiator currently supports the following text editing features (including keyboard shortcuts with Mac CMD=CTRL on Windows/Linux):
|
15
|
+
- File explorer navigation with context menu to open file, rename, delete, add new file, add new directory, or refresh tree (CMD+T)
|
13
16
|
- File lookup by name ignoring slashes, underscores, and dots to ease lookup (CMD+R)
|
14
17
|
- Watch open file for external changes to automatically refresh in editor
|
15
18
|
- Watch project subdirectories for changes to automatically refresh in file explorer/file lookup
|
@@ -26,34 +29,69 @@ Gladiator currently supports the following text editing features:
|
|
26
29
|
- Comment/Uncomment line/selection (CMD+/)
|
27
30
|
- Indent/Unindent line/selection (CMD+] & CMD+[)
|
28
31
|
- Insert/Prefix New Line (CMD+ENTER & CMD+SHIFT+ENTER)
|
32
|
+
- Drag and Drop Text Editor Split Screen (drag a file from File Tree or File Lookup List, and it splits the screen)
|
29
33
|
|
30
34
|
## Platforms
|
31
35
|
|
32
|
-
- Mac: Gladiator works best on the Mac.
|
33
|
-
-
|
34
|
-
-
|
36
|
+
- Mac: Gladiator works best on the Mac. This is the platform it is most used on and receives the most maintenance for.
|
37
|
+
- Windows: Gladiator works OK on Windows, but has some annoying bugs.
|
38
|
+
- Linux: Gladiator works with very bad handicaps on Linux (performing text editing operations causes scroll jitter)
|
35
39
|
|
36
40
|
## Pre-requisites
|
37
41
|
|
38
|
-
- [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer) (
|
39
|
-
- [JRuby](https://www.jruby.org/download): Same version required by [Glimmer](https://github.com/AndyObtiva/glimmer)
|
40
|
-
- [JDK](https://www.oracle.com/java/technologies/javase-downloads.html): Same version required by [Glimmer](https://github.com/AndyObtiva/glimmer)
|
42
|
+
- [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) (JRuby Desktop Development GUI Library): '>= 4.17.2.0', '< 5.0.0.0' (dependency included in Ruby gem).
|
43
|
+
- [JRuby](https://www.jruby.org/download): Same version required by [Glimmer](https://github.com/AndyObtiva/glimmer-dsl-swt)
|
44
|
+
- [JDK](https://www.oracle.com/java/technologies/javase-downloads.html): Same version required by [Glimmer](https://github.com/AndyObtiva/glimmer-dsl-swt)
|
41
45
|
|
42
46
|
## Setup Instructions
|
43
47
|
|
44
|
-
Install Gladiator gem by running (`jgem`, `jruby -S gem`, or `gem` directly if you have RVM):
|
48
|
+
Install Gladiator gem by running (`jgem`, `jruby -S gem`, or `gem` directly if you have [RVM](https://rvm.io/)):
|
45
49
|
|
46
50
|
```
|
47
51
|
jgem install glimmer-cs-gladiator
|
48
52
|
```
|
49
53
|
|
50
|
-
|
54
|
+
Or add to a JRuby project Bundler `Gemfile` under the `:developement` group:
|
55
|
+
|
56
|
+
```
|
57
|
+
group :development do
|
58
|
+
gem 'glimmer-cs-gladiator'
|
59
|
+
end
|
60
|
+
```
|
61
|
+
|
62
|
+
Run (`jruby -S bundle` or `bundle` directly if you have [RVM](https://rvm.io/)):
|
63
|
+
|
64
|
+
```
|
65
|
+
jruby -S bundle
|
66
|
+
```
|
67
|
+
|
68
|
+
## Usage
|
69
|
+
|
70
|
+
You may run the `gladiator` command to bring up the text editor in the project directory you would like to edit:
|
51
71
|
|
52
72
|
```
|
53
73
|
gladiator
|
54
74
|
```
|
55
75
|
|
56
|
-
|
76
|
+
On Windows, you may need to run with extra memory via this command instead:
|
77
|
+
|
78
|
+
```
|
79
|
+
gladiator -J-Xmx3000M
|
80
|
+
```
|
81
|
+
|
82
|
+
If you are in a different directory from the project you would like to edit, then pass its path as an argument:
|
83
|
+
|
84
|
+
```
|
85
|
+
gladiator relative-or-absolute-path/to/project
|
86
|
+
```
|
87
|
+
|
88
|
+
Note: If you cloned this project and bundle installed, you may invoke via `bin/gladiator` instead.
|
89
|
+
|
90
|
+
If your project is not a JRuby project, then you cannot install [glimmer-cs-gladiator](https://rubygems.org/gems/glimmer-cs-gladiator), so you must install in a separate JRuby environment and invoke by passing the project path as per command above. Alternatively, you may clone this project, and invoke gladiator via `bin/gladiator` (that's how I use Gladiator for most of my projects):
|
91
|
+
|
92
|
+
```
|
93
|
+
bin/gladiator relative-or-absolute-path/to/project
|
94
|
+
```
|
57
95
|
|
58
96
|
### Glimmer Custom Shell Reuse
|
59
97
|
|
@@ -61,7 +99,7 @@ To reuse Gladiator as a Glimmer Custom Shell inside another Glimmer application,
|
|
61
99
|
following to the application's `Gemfile`:
|
62
100
|
|
63
101
|
```
|
64
|
-
gem 'glimmer-cs-gladiator', '0.
|
102
|
+
gem 'glimmer-cs-gladiator', '~> 0.3.0'
|
65
103
|
```
|
66
104
|
|
67
105
|
Run:
|
@@ -70,7 +108,7 @@ Run:
|
|
70
108
|
jruby -S bundle
|
71
109
|
```
|
72
110
|
|
73
|
-
And, then instantiate the Gladiator custom shell in your Glimmer application via the `gladiator` keyword.
|
111
|
+
And, then instantiate the Gladiator [custom shell](https://github.com/AndyObtiva/glimmer-dsl-swt#custom-shells) in your [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) application via the `gladiator` keyword assuming you already have `include Glimmer` in your class, module, or main object.
|
74
112
|
|
75
113
|
## Env Var Options
|
76
114
|
|
@@ -93,6 +131,8 @@ It currently remembers:
|
|
93
131
|
- Last opened file
|
94
132
|
- Caret position
|
95
133
|
- Top line position
|
134
|
+
- Opened tabs
|
135
|
+
- Ignore Paths
|
96
136
|
|
97
137
|
## Gotcha
|
98
138
|
|
@@ -119,5 +159,12 @@ The signal TERM is in use by the JVM and will not work correctly on this platfor
|
|
119
159
|
|
120
160
|
## Copyright
|
121
161
|
|
122
|
-
|
123
|
-
|
162
|
+
[MIT](https://opensource.org/licenses/MIT)
|
163
|
+
|
164
|
+
Copyright (c) 2020 Andy Maleh. See [LICENSE.txt](LICENSE.txt) for further details.
|
165
|
+
|
166
|
+
--
|
167
|
+
|
168
|
+
[<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=40 />](https://github.com/AndyObtiva/glimmer) Built with [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) (JRuby Desktop Development GUI Library)
|
169
|
+
|
170
|
+
Gladiator icon made by <a href="https://www.flaticon.com/authors/freepik" title="Freepik">Freepik</a> from <a href="https://www.flaticon.com/" title="Flaticon">www.flaticon.com</a>
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/lib/glimmer-cs-gladiator.rb
CHANGED
@@ -2,4 +2,28 @@ $LOAD_PATH.unshift(File.expand_path('..', __FILE__))
|
|
2
2
|
|
3
3
|
require 'filewatcher'
|
4
4
|
require 'clipboard'
|
5
|
+
require 'puts_debuggerer'
|
5
6
|
require 'views/glimmer/gladiator'
|
7
|
+
|
8
|
+
# Custom Composite Initializer (avoid default margins)
|
9
|
+
Glimmer::SWT::WidgetProxy::DEFAULT_INITIALIZERS['composite'] = lambda do |composite|
|
10
|
+
if composite.get_layout.nil?
|
11
|
+
layout = GridLayout.new
|
12
|
+
composite.layout = layout
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# Custom LayoutProxy initialize method (avoid default margins)
|
17
|
+
module Glimmer
|
18
|
+
module SWT
|
19
|
+
class LayoutProxy
|
20
|
+
def initialize(underscored_layout_name, widget_proxy, args)
|
21
|
+
@underscored_layout_name = underscored_layout_name
|
22
|
+
@widget_proxy = widget_proxy
|
23
|
+
args = SWTProxy.constantify_args(args)
|
24
|
+
@swt_layout = self.class.swt_layout_class_for(underscored_layout_name).new(*args)
|
25
|
+
@widget_proxy.swt_widget.setLayout(@swt_layout)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -9,32 +9,44 @@ module Glimmer
|
|
9
9
|
|
10
10
|
class << self
|
11
11
|
def local_dir
|
12
|
-
@local_dir
|
13
|
-
|
14
|
-
|
12
|
+
unless @local_dir
|
13
|
+
@local_dir = new(ENV['LOCAL_DIR'] || '.', true)
|
14
|
+
# @local_dir.refresh
|
15
|
+
@filewatcher = Filewatcher.new(@local_dir.path)
|
15
16
|
@thread = Thread.new(@filewatcher) do |fw|
|
16
17
|
fw.watch do |filename, event|
|
17
18
|
if @last_update.nil? || (Time.now.to_f - @last_update) > REFRESH_DELAY
|
18
|
-
|
19
|
+
@local_dir.refresh if !filename.include?('new_file') && !@local_dir.selected_child_path_history.include?(filename) && filename != @local_dir.selected_child_path
|
19
20
|
end
|
20
21
|
@last_update = Time.now.to_f
|
21
22
|
end
|
22
23
|
end
|
23
24
|
end
|
25
|
+
@local_dir
|
24
26
|
end
|
25
27
|
end
|
26
28
|
|
27
|
-
attr_accessor :selected_child, :filter, :children, :filtered_path_options, :filtered_path, :
|
28
|
-
attr_reader :name, :parent
|
29
|
-
attr_writer :all_children
|
29
|
+
attr_accessor :selected_child, :filter, :children, :filtered_path_options, :filtered_path, :display_path, :ignore_paths
|
30
|
+
attr_reader :name, :parent, :path, :is_local_dir
|
31
|
+
attr_writer :all_children
|
30
32
|
|
31
|
-
def initialize(path)
|
32
|
-
@
|
33
|
-
|
33
|
+
def initialize(path, is_local_dir = false)
|
34
|
+
@is_local_dir = is_local_dir
|
35
|
+
self.path = ::File.expand_path(path)
|
34
36
|
@name = ::File.basename(::File.expand_path(path))
|
37
|
+
@ignore_paths = ['packages', 'tmp']
|
35
38
|
self.filtered_path_options = []
|
36
39
|
end
|
37
40
|
|
41
|
+
def path=(the_path)
|
42
|
+
@path = the_path
|
43
|
+
generate_display_path
|
44
|
+
end
|
45
|
+
|
46
|
+
def generate_display_path
|
47
|
+
is_local_dir ? path : @display_path = @path.sub(Dir.local_dir.path, '').sub(/^\//, '')
|
48
|
+
end
|
49
|
+
|
38
50
|
def name=(the_name)
|
39
51
|
self.display_path = display_path.sub(/#{Regexp.escape(@name)}$/, the_name)
|
40
52
|
@name = the_name
|
@@ -48,7 +60,20 @@ module Glimmer
|
|
48
60
|
end
|
49
61
|
|
50
62
|
def retrieve_children
|
51
|
-
::Dir.glob(::File.join(@
|
63
|
+
@children = ::Dir.glob(::File.join(@path, '*')).reject do |p|
|
64
|
+
# TODO make sure to configure ignore_paths in a preferences dialog
|
65
|
+
Dir.local_dir.ignore_paths.reduce(false) do |result, ignore_path|
|
66
|
+
result || p.include?(ignore_path)
|
67
|
+
end
|
68
|
+
end.map do |p|
|
69
|
+
::File.file?(p) ? Gladiator::File.new(p) : Gladiator::Dir.new(p)
|
70
|
+
end.sort_by do |c|
|
71
|
+
c.path.to_s.downcase
|
72
|
+
end.sort_by do |c|
|
73
|
+
c.class.name
|
74
|
+
end.each do |child|
|
75
|
+
child.retrieve_children if child.is_a?(Dir)
|
76
|
+
end
|
52
77
|
end
|
53
78
|
|
54
79
|
def selected_child_path_history
|
@@ -65,11 +90,11 @@ module Glimmer
|
|
65
90
|
|
66
91
|
def refresh(async: true, force: false)
|
67
92
|
return if @refresh_paused && !force
|
68
|
-
|
69
|
-
|
93
|
+
retrieve_children
|
94
|
+
collect_all_children
|
70
95
|
refresh_operation = lambda do
|
71
|
-
|
72
|
-
|
96
|
+
notify_observers(:children)
|
97
|
+
notify_observers(:all_children)
|
73
98
|
end
|
74
99
|
if async
|
75
100
|
async_exec(&refresh_operation)
|
@@ -84,23 +109,31 @@ module Glimmer
|
|
84
109
|
else
|
85
110
|
@filter = value
|
86
111
|
end
|
87
|
-
|
112
|
+
@last_filtered = filtered.to_a
|
113
|
+
self.filtered_path_options = @last_filtered.map(&:display_path)
|
114
|
+
@last_filter = @filter
|
88
115
|
end
|
89
116
|
|
90
117
|
def filtered
|
91
118
|
return if filter.nil?
|
92
|
-
|
93
|
-
|
94
|
-
|
119
|
+
children_files = !@last_filter.to_s.empty? && filter.downcase.start_with?(@last_filter.downcase) ? @last_filtered : all_children_files
|
120
|
+
children_files.select do |child|
|
121
|
+
child_path = child.path.to_s.sub(Dir.local_dir.path, '')
|
122
|
+
child_path.downcase.include?(filter.downcase) ||
|
123
|
+
child_path.downcase.gsub(/[_\/.-]/, '').include?(filter.downcase.gsub(/[_\/.-]/, ''))
|
95
124
|
end.sort_by {|c| c.path.to_s.downcase}
|
96
125
|
end
|
97
126
|
|
98
127
|
def all_children
|
99
|
-
@all_children ||=
|
128
|
+
@all_children ||= collect_all_children
|
100
129
|
end
|
101
130
|
|
102
|
-
def
|
103
|
-
|
131
|
+
def collect_all_children
|
132
|
+
@all_children = children.reduce([]) do |output, child|
|
133
|
+
addition = [child]
|
134
|
+
addition += child.collect_all_children if child.is_a?(Dir)
|
135
|
+
output + addition
|
136
|
+
end
|
104
137
|
end
|
105
138
|
|
106
139
|
def all_children_files
|
@@ -108,9 +141,11 @@ module Glimmer
|
|
108
141
|
end
|
109
142
|
|
110
143
|
def selected_child_path=(selected_path)
|
144
|
+
full_selected_path = selected_path.include?(Dir.local_dir.path) ? selected_path : ::File.join(Dir.local_dir.path, selected_path)
|
111
145
|
return if selected_path.nil? ||
|
112
|
-
::Dir.exist?(
|
113
|
-
(selected_child &&
|
146
|
+
::Dir.exist?(full_selected_path) ||
|
147
|
+
(selected_child && selected_child.path == full_selected_path)
|
148
|
+
selected_path = full_selected_path
|
114
149
|
if ::File.file?(selected_path)
|
115
150
|
@selected_child&.write_dirty_content
|
116
151
|
new_child = Gladiator::File.new(selected_path)
|
@@ -5,15 +5,14 @@ module Glimmer
|
|
5
5
|
class File
|
6
6
|
include Glimmer
|
7
7
|
|
8
|
-
attr_accessor :dirty_content, :line_numbers_content, :selection, :selection_count, :line_number, :find_text, :replace_text, :top_index, :
|
9
|
-
attr_reader :name
|
8
|
+
attr_accessor :dirty_content, :line_numbers_content, :selection, :selection_count, :line_number, :find_text, :replace_text, :top_index, :display_path, :case_sensitive
|
9
|
+
attr_reader :name, :path
|
10
10
|
|
11
11
|
def initialize(path)
|
12
12
|
raise "Not a file path: #{path}" unless ::File.file?(path)
|
13
13
|
@command_history = []
|
14
|
-
@display_path = path
|
15
14
|
@name = ::File.basename(path)
|
16
|
-
|
15
|
+
self.path = ::File.expand_path(path)
|
17
16
|
@top_index = 0
|
18
17
|
@selection_count = 0
|
19
18
|
@selection = Point.new(0, 0 + @selection_count)
|
@@ -42,6 +41,15 @@ module Glimmer
|
|
42
41
|
end
|
43
42
|
end
|
44
43
|
|
44
|
+
def path=(the_path)
|
45
|
+
@path = the_path
|
46
|
+
generate_display_path
|
47
|
+
end
|
48
|
+
|
49
|
+
def generate_display_path
|
50
|
+
@display_path = @path.sub(Dir.local_dir.path, '').sub(/^\//, '')
|
51
|
+
end
|
52
|
+
|
45
53
|
# to use for widget data-binding
|
46
54
|
def content=(value)
|
47
55
|
Command.do(self) # record a native (OS-widget) operation
|
@@ -66,11 +74,12 @@ module Glimmer
|
|
66
74
|
end
|
67
75
|
|
68
76
|
def name=(the_name)
|
69
|
-
|
77
|
+
new_path = path.sub(/#{Regexp.escape(@name)}$/, the_name)
|
70
78
|
@name = the_name
|
71
|
-
|
72
|
-
|
73
|
-
|
79
|
+
if ::File.exists?(path)
|
80
|
+
FileUtils.mv(path, new_path)
|
81
|
+
self.path = new_path
|
82
|
+
end
|
74
83
|
end
|
75
84
|
|
76
85
|
def dirty_content=(the_content)
|
@@ -223,7 +232,7 @@ module Glimmer
|
|
223
232
|
if the_line.to_s.start_with?(' ')
|
224
233
|
new_lines[the_line_index] = the_line.sub(/ /, '')
|
225
234
|
delta = -2
|
226
|
-
elsif the_line
|
235
|
+
elsif the_line&.start_with?(' ')
|
227
236
|
new_lines[the_line_index] = the_line.sub(/ /, '')
|
228
237
|
delta = -1
|
229
238
|
end
|
@@ -1,8 +1,3 @@
|
|
1
|
-
begin
|
2
|
-
require 'puts_debuggerer' if ENV['puts_debuggerer'].to_s.downcase == 'true'
|
3
|
-
rescue LoadError
|
4
|
-
# no op
|
5
|
-
end
|
6
1
|
require 'fileutils'
|
7
2
|
require 'os'
|
8
3
|
|
@@ -12,8 +7,6 @@ require 'models/glimmer/gladiator/command'
|
|
12
7
|
|
13
8
|
require 'views/glimmer/gladiator/text_editor'
|
14
9
|
|
15
|
-
java_import 'org.eclipse.swt.custom.TreeEditor'
|
16
|
-
|
17
10
|
Clipboard.implementation = Clipboard::Java
|
18
11
|
Clipboard.copy(Clipboard.paste) # pre-initialize library to avoid slowdown during use
|
19
12
|
|
@@ -24,19 +17,24 @@ module Glimmer
|
|
24
17
|
|
25
18
|
COMMAND_KEY = OS.mac? ? :command : :ctrl
|
26
19
|
|
20
|
+
class << self
|
21
|
+
attr_accessor :drag_and_drop
|
22
|
+
attr_accessor :drag
|
23
|
+
end
|
24
|
+
|
27
25
|
## Add options like the following to configure CustomShell by outside consumers
|
28
26
|
#
|
29
27
|
# options :title, :background_color
|
30
28
|
# option :width, 320
|
31
29
|
# option :height, 240
|
32
|
-
|
30
|
+
|
33
31
|
## Uncomment before_body block to pre-initialize variables to use in body
|
34
32
|
#
|
35
33
|
#
|
36
34
|
before_body {
|
37
35
|
Display.setAppName('Gladiator')
|
38
36
|
@display = display {
|
39
|
-
|
37
|
+
on_swt_keydown { |key_event|
|
40
38
|
if key_event.stateMask == swt(COMMAND_KEY) && extract_char(key_event) == 'f'
|
41
39
|
if @text_editor&.text_widget&.getSelectionText && @text_editor&.text_widget&.getSelectionText&.size.to_i > 0
|
42
40
|
@find_text.swt_widget.setText @text_editor.text_widget.getSelectionText
|
@@ -44,69 +42,93 @@ module Glimmer
|
|
44
42
|
@find_text.swt_widget.selectAll
|
45
43
|
@find_text.swt_widget.setFocus
|
46
44
|
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY, :shift) && extract_char(key_event) == 'c'
|
47
|
-
Clipboard.copy(
|
45
|
+
Clipboard.copy(Dir.local_dir.selected_child.path)
|
48
46
|
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY, :shift) && extract_char(key_event) == 'g'
|
49
|
-
|
47
|
+
Dir.local_dir.selected_child.find_previous
|
50
48
|
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY, :shift) && extract_char(key_event) == 'w'
|
51
49
|
@tab_folder.swt_widget.getItems.each do |tab_item|
|
52
50
|
Dir.local_dir.selected_child_path_history.delete(tab_item.getData('file_path'))
|
53
|
-
tab_item.getData('proxy')
|
51
|
+
tab_item.getData('proxy')&.dispose
|
54
52
|
end
|
53
|
+
close_tab_folder
|
55
54
|
@tab_item = @text_editor = Dir.local_dir.selected_child = nil
|
56
55
|
@filter_text.swt_widget.selectAll
|
57
56
|
@filter_text.swt_widget.setFocus
|
58
57
|
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY, :alt) && extract_char(key_event) == 'w'
|
59
58
|
other_tab_items.each do |tab_item|
|
60
59
|
Dir.local_dir.selected_child_path_history.delete(tab_item.getData('file_path'))
|
61
|
-
tab_item.getData('proxy')
|
60
|
+
tab_item.getData('proxy')&.dispose
|
62
61
|
end
|
63
62
|
elsif key_event.stateMask == swt(COMMAND_KEY) && extract_char(key_event) == 'w'
|
64
63
|
if selected_tab_item
|
65
64
|
Dir.local_dir.selected_child_path_history.delete(Dir.local_dir.selected_child.path)
|
66
|
-
selected_tab_item.getData('proxy')
|
65
|
+
selected_tab_item.getData('proxy')&.dispose
|
66
|
+
close_tab_folder
|
67
67
|
if selected_tab_item.nil?
|
68
68
|
@tab_item = @text_editor = Dir.local_dir.selected_child = nil
|
69
69
|
@filter_text.swt_widget.selectAll
|
70
70
|
@filter_text.swt_widget.setFocus
|
71
71
|
else
|
72
|
-
@text_editor
|
72
|
+
@text_editor&.text_widget&.setFocus
|
73
73
|
end
|
74
74
|
end
|
75
75
|
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY, :shift) && extract_char(key_event) == ']'
|
76
76
|
@tab_folder.swt_widget.setSelection((@tab_folder.swt_widget.getSelectionIndex() + 1) % @tab_folder.swt_widget.getItemCount) if @tab_folder.swt_widget.getItemCount > 0
|
77
|
-
@text_editor
|
77
|
+
@text_editor&.text_widget&.setFocus
|
78
78
|
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY, :shift) && extract_char(key_event) == '['
|
79
79
|
@tab_folder.swt_widget.setSelection((@tab_folder.swt_widget.getSelectionIndex() - 1) % @tab_folder.swt_widget.getItemCount) if @tab_folder.swt_widget.getItemCount > 0
|
80
|
-
@text_editor
|
80
|
+
@text_editor&.text_widget&.setFocus
|
81
|
+
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY, :ctrl) && extract_char(key_event) == ']'
|
82
|
+
if @tab_folder2
|
83
|
+
if @tab_folder == @tab_folder1
|
84
|
+
@tab_folder = @tab_folder2
|
85
|
+
else
|
86
|
+
@tab_folder = @tab_folder1
|
87
|
+
end
|
88
|
+
@tab_item = @tab_folder.swt_widget.getData('selected_tab_item')
|
89
|
+
Dir.local_dir.selected_child = @tab_item&.swt_tab_item&.getData('file')
|
90
|
+
@tab_item&.swt_tab_item&.getData('text_editor')&.text_widget&.setFocus
|
91
|
+
end
|
92
|
+
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY, :ctrl) && extract_char(key_event) == '['
|
93
|
+
if @tab_folder2
|
94
|
+
if @tab_folder == @tab_folder2
|
95
|
+
@tab_folder = @tab_folder1
|
96
|
+
else
|
97
|
+
@tab_folder = @tab_folder2
|
98
|
+
end
|
99
|
+
@tab_item = @tab_folder.swt_widget.getData('selected_tab_item')
|
100
|
+
Dir.local_dir.selected_child = @tab_item&.swt_tab_item&.getData('file')
|
101
|
+
@tab_item&.swt_tab_item&.getData('text_editor')&.text_widget&.setFocus
|
102
|
+
end
|
81
103
|
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY) && extract_char(key_event) == '1'
|
82
104
|
@tab_folder.swt_widget.setSelection(0) if @tab_folder.swt_widget.getItemCount >= 1
|
83
|
-
@text_editor
|
105
|
+
@text_editor&.text_widget&.setFocus
|
84
106
|
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY) && extract_char(key_event) == '2'
|
85
107
|
@tab_folder.swt_widget.setSelection(1) if @tab_folder.swt_widget.getItemCount >= 2
|
86
|
-
@text_editor
|
108
|
+
@text_editor&.text_widget&.setFocus
|
87
109
|
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY) && extract_char(key_event) == '3'
|
88
110
|
@tab_folder.swt_widget.setSelection(2) if @tab_folder.swt_widget.getItemCount >= 3
|
89
|
-
@text_editor
|
111
|
+
@text_editor&.text_widget&.setFocus
|
90
112
|
@tab_folder.swt_widget.setSelection(3) if @tab_folder.swt_widget.getItemCount >= 4
|
91
|
-
@text_editor
|
113
|
+
@text_editor&.text_widget&.setFocus
|
92
114
|
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY) && extract_char(key_event) == '5'
|
93
115
|
@tab_folder.swt_widget.setSelection(4) if @tab_folder.swt_widget.getItemCount >= 5
|
94
|
-
@text_editor
|
116
|
+
@text_editor&.text_widget&.setFocus
|
95
117
|
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY) && extract_char(key_event) == '4'
|
96
118
|
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY) && extract_char(key_event) == '6'
|
97
119
|
@tab_folder.swt_widget.setSelection(5) if @tab_folder.swt_widget.getItemCount >= 6
|
98
|
-
@text_editor
|
120
|
+
@text_editor&.text_widget&.setFocus
|
99
121
|
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY) && extract_char(key_event) == '7'
|
100
122
|
@tab_folder.swt_widget.setSelection(6) if @tab_folder.swt_widget.getItemCount >= 7
|
101
|
-
@text_editor
|
123
|
+
@text_editor&.text_widget&.setFocus
|
102
124
|
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY) && extract_char(key_event) == '8'
|
103
125
|
@tab_folder.swt_widget.setSelection(7) if @tab_folder.swt_widget.getItemCount >= 8
|
104
|
-
@text_editor
|
126
|
+
@text_editor&.text_widget&.setFocus
|
105
127
|
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY) && extract_char(key_event) == '9'
|
106
128
|
@tab_folder.swt_widget.setSelection(@tab_folder.swt_widget.getItemCount - 1) if @tab_folder.swt_widget.getItemCount > 0
|
107
|
-
@text_editor
|
129
|
+
@text_editor&.text_widget&.setFocus
|
108
130
|
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY) && extract_char(key_event) == 'g'
|
109
|
-
|
131
|
+
Dir.local_dir.selected_child.find_next
|
110
132
|
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY) && extract_char(key_event) == 'l'
|
111
133
|
@line_number_text.swt_widget.selectAll
|
112
134
|
@line_number_text.swt_widget.setFocus
|
@@ -119,7 +141,7 @@ module Glimmer
|
|
119
141
|
elsif key_event.keyCode == swt(:esc)
|
120
142
|
if @text_editor
|
121
143
|
Dir.local_dir.selected_child_path = @text_editor.file.path
|
122
|
-
@text_editor
|
144
|
+
@text_editor&.text_widget&.setFocus
|
123
145
|
end
|
124
146
|
end
|
125
147
|
}
|
@@ -128,51 +150,80 @@ module Glimmer
|
|
128
150
|
local_dir = ENV['LOCAL_DIR'] || '.'
|
129
151
|
@config_file_path = ::File.join(local_dir, '.gladiator')
|
130
152
|
@config = {}
|
131
|
-
|
153
|
+
load_config_ignore_paths
|
154
|
+
# Dir.local_dir.all_children # pre-caches children
|
132
155
|
}
|
133
156
|
|
134
157
|
## Uncomment after_body block to setup observers for widgets in body
|
135
158
|
#
|
136
159
|
after_body {
|
137
|
-
observe(
|
160
|
+
observe(Dir.local_dir, 'children') do
|
138
161
|
select_tree_item unless @rename_in_progress
|
139
162
|
end
|
140
|
-
observe(
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
@text_editor = found_tab_item.getData('text_editor')
|
148
|
-
elsif selected_file
|
149
|
-
@tab_folder.content {
|
150
|
-
@tab_item = tab_item { |the_tab_item|
|
151
|
-
text selected_file.name
|
152
|
-
fill_layout :horizontal
|
153
|
-
@text_editor = the_text_editor = text_editor(file: selected_file)
|
154
|
-
on_event_show {
|
155
|
-
Gladiator::Dir.local_dir.selected_child = selected_file
|
156
|
-
@tab_item = the_tab_item
|
157
|
-
@text_editor = the_text_editor
|
158
|
-
}
|
163
|
+
observe(Dir.local_dir, 'selected_child') do |selected_file|
|
164
|
+
if selected_file
|
165
|
+
if Gladiator.drag && !@tab_folder2
|
166
|
+
@tab_folder1 = @tab_folder
|
167
|
+
@tab_folder_sash_form.content {
|
168
|
+
@tab_folder = @tab_folder2 = tab_folder
|
169
|
+
@tab_folder.swt_widget.setData('proxy', @tab_folder)
|
159
170
|
}
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
171
|
+
end
|
172
|
+
select_tree_item unless @rename_in_progress
|
173
|
+
found_tab_item = selected_tab_item
|
174
|
+
if found_tab_item
|
175
|
+
@tab_folder.swt_widget.setSelection(found_tab_item)
|
176
|
+
@tab_item = found_tab_item.getData('proxy')
|
177
|
+
@text_editor = found_tab_item.getData('text_editor')
|
178
|
+
@tab_folder.swt_widget.setData('selected_tab_item', @tab_item)
|
179
|
+
elsif selected_file
|
180
|
+
@tab_folder.content {
|
181
|
+
@tab_item = tab_item { |the_tab_item|
|
182
|
+
text selected_file.name
|
183
|
+
fill_layout :horizontal
|
184
|
+
@text_editor = the_text_editor = text_editor(file: selected_file)
|
185
|
+
@tab_folder.swt_widget.setData('selected_tab_item', @tab_item)
|
186
|
+
@text_editor.text_proxy.content {
|
187
|
+
on_focus_gained {
|
188
|
+
tab_folder = the_text_editor.swt_widget.getParent.getParent
|
189
|
+
@tab_folder = tab_folder.getData('proxy')
|
190
|
+
@tab_item = the_tab_item
|
191
|
+
@text_editor = the_text_editor
|
192
|
+
@tab_folder.swt_widget.setData('selected_tab_item', @tab_item)
|
193
|
+
@tab_folder.swt_widget.setSelection(@tab_item.swt_tab_item)
|
194
|
+
Dir.local_dir.selected_child = @tab_item.swt_tab_item.getData('file')
|
195
|
+
}
|
196
|
+
}
|
197
|
+
on_swt_show {
|
198
|
+
@tab_item = the_tab_item
|
199
|
+
@text_editor = the_text_editor
|
200
|
+
@tab_folder = @tab_item.swt_widget.getParent.getData('proxy')
|
201
|
+
@tab_folder.swt_widget.setData('selected_tab_item', @tab_item)
|
202
|
+
@tab_folder.swt_widget.setSelection(@tab_item.swt_tab_item)
|
203
|
+
Dir.local_dir.selected_child = selected_file
|
204
|
+
async_exec {
|
205
|
+
@text_editor&.text_widget&.setFocus
|
206
|
+
}
|
207
|
+
}
|
208
|
+
}
|
209
|
+
@tab_item.swt_tab_item.setData('file_path', selected_file.path)
|
210
|
+
@tab_item.swt_tab_item.setData('file', selected_file)
|
211
|
+
@tab_item.swt_tab_item.setData('text_editor', @text_editor)
|
212
|
+
@tab_item.swt_tab_item.setData('proxy', @tab_item)
|
213
|
+
}
|
214
|
+
@tab_folder.swt_widget.setSelection(@tab_item.swt_tab_item)
|
215
|
+
body_root.pack_same_size
|
216
|
+
end
|
217
|
+
@text_editor&.text_widget&.setFocus
|
167
218
|
end
|
168
219
|
end
|
169
|
-
observe(
|
220
|
+
observe(Dir.local_dir, 'selected_child') do
|
170
221
|
save_config
|
171
222
|
end
|
172
|
-
observe(
|
223
|
+
observe(Dir.local_dir, 'selected_child.caret_position') do
|
173
224
|
save_config
|
174
225
|
end
|
175
|
-
observe(
|
226
|
+
observe(Dir.local_dir, 'selected_child.top_index') do
|
176
227
|
save_config
|
177
228
|
end
|
178
229
|
load_config
|
@@ -183,15 +234,20 @@ module Glimmer
|
|
183
234
|
#
|
184
235
|
body {
|
185
236
|
shell {
|
186
|
-
text "Gladiator - #{::File.expand_path(
|
187
|
-
minimum_size
|
237
|
+
text "Gladiator - #{::File.expand_path(Dir.local_dir.path)}"
|
238
|
+
minimum_size 520, 250
|
188
239
|
size 1440, 900
|
189
|
-
grid_layout
|
190
|
-
|
191
|
-
|
240
|
+
grid_layout(2, false)
|
241
|
+
on_swt_show {
|
242
|
+
swt_widget.setSize(@config[:shell_width], @config[:shell_height]) if @config[:shell_width] && @config[:shell_height]
|
243
|
+
swt_widget.setLocation(@config[:shell_x], @config[:shell_y]) if @config[:shell_x] && @config[:shell_y]
|
244
|
+
@loaded_config = true
|
245
|
+
}
|
246
|
+
on_swt_close {
|
247
|
+
Dir.local_dir.selected_child&.write_dirty_content
|
192
248
|
}
|
193
249
|
on_widget_disposed {
|
194
|
-
|
250
|
+
Dir.local_dir.selected_child&.write_dirty_content
|
195
251
|
}
|
196
252
|
on_control_resized {
|
197
253
|
save_config
|
@@ -209,7 +265,7 @@ module Glimmer
|
|
209
265
|
}
|
210
266
|
@filter_text = text {
|
211
267
|
layout_data :fill, :center, true, false
|
212
|
-
text bind(
|
268
|
+
text bind(Dir.local_dir, 'filter')
|
213
269
|
on_key_pressed { |key_event|
|
214
270
|
if key_event.keyCode == swt(:tab) ||
|
215
271
|
key_event.keyCode == swt(:cr) ||
|
@@ -226,26 +282,43 @@ module Glimmer
|
|
226
282
|
}
|
227
283
|
layout_data(:fill, :fill, true, true)
|
228
284
|
@list = list(:border, :h_scroll, :v_scroll) {
|
229
|
-
#visible bind(
|
230
|
-
selection bind(
|
285
|
+
#visible bind(Dir, 'local_dir.filter') {|f| !!f}
|
286
|
+
selection bind(Dir.local_dir, :filtered_path)
|
231
287
|
on_mouse_up {
|
232
|
-
|
288
|
+
Dir.local_dir.selected_child_path = @list.swt_widget.getSelection.first
|
233
289
|
}
|
234
290
|
on_key_pressed { |key_event|
|
235
291
|
if Glimmer::SWT::SWTProxy.include?(key_event.keyCode, :cr)
|
236
|
-
|
292
|
+
Dir.local_dir.selected_child_path = @list.swt_widget.getSelection.first
|
237
293
|
@text_editor&.text_widget&.setFocus
|
238
294
|
end
|
239
295
|
}
|
296
|
+
drag_source(DND::DROP_COPY) {
|
297
|
+
transfer [TextTransfer.getInstance].to_java(Transfer)
|
298
|
+
on_drag_set_data { |event|
|
299
|
+
Gladiator.drag = true
|
300
|
+
list = event.widget.getControl
|
301
|
+
event.data = list.getSelection.first
|
302
|
+
}
|
303
|
+
}
|
240
304
|
}
|
241
305
|
@tree = tree(:virtual, :border, :h_scroll, :v_scroll) {
|
242
|
-
#visible bind(
|
243
|
-
items bind(
|
306
|
+
#visible bind(Dir, 'local_dir.filter') {|f| !f}
|
307
|
+
items bind(Dir, :local_dir), tree_properties(children: :children, text: :name)
|
308
|
+
drag_source(DND::DROP_COPY) {
|
309
|
+
transfer [TextTransfer.getInstance].to_java(Transfer)
|
310
|
+
on_drag_set_data { |event|
|
311
|
+
Gladiator.drag = true
|
312
|
+
tree = event.widget.getControl
|
313
|
+
tree_item = tree.getSelection.first
|
314
|
+
event.data = tree_item.getData.path
|
315
|
+
}
|
316
|
+
}
|
244
317
|
menu {
|
245
318
|
@open_menu_item = menu_item {
|
246
319
|
text 'Open'
|
247
320
|
on_widget_selected {
|
248
|
-
|
321
|
+
Dir.local_dir.selected_child_path = extract_tree_item_path(@tree.swt_widget.getSelection.first)
|
249
322
|
}
|
250
323
|
}
|
251
324
|
menu_item(:separator)
|
@@ -259,7 +332,7 @@ module Glimmer
|
|
259
332
|
menu_item {
|
260
333
|
text 'Refresh'
|
261
334
|
on_widget_selected {
|
262
|
-
|
335
|
+
Dir.local_dir.refresh
|
263
336
|
}
|
264
337
|
}
|
265
338
|
menu_item {
|
@@ -281,17 +354,21 @@ module Glimmer
|
|
281
354
|
}
|
282
355
|
}
|
283
356
|
}
|
284
|
-
|
357
|
+
on_swt_menudetect { |event|
|
285
358
|
path = extract_tree_item_path(@tree.swt_widget.getSelection.first)
|
286
359
|
@open_menu_item.swt_widget.setEnabled(!::Dir.exist?(path)) if path
|
287
360
|
}
|
288
361
|
on_mouse_up {
|
289
|
-
Gladiator
|
290
|
-
|
362
|
+
if Gladiator.drag_and_drop
|
363
|
+
Gladiator.drag_and_drop = false
|
364
|
+
else
|
365
|
+
Dir.local_dir.selected_child_path = extract_tree_item_path(@tree.swt_widget.getSelection&.first)
|
366
|
+
@text_editor&.text_widget&.setFocus
|
367
|
+
end
|
291
368
|
}
|
292
369
|
on_key_pressed { |key_event|
|
293
370
|
if Glimmer::SWT::SWTProxy.include?(key_event.keyCode, :cr)
|
294
|
-
|
371
|
+
Dir.local_dir.selected_child_path = extract_tree_item_path(@tree.swt_widget.getSelection&.first)
|
295
372
|
@text_editor&.text_widget&.setFocus
|
296
373
|
end
|
297
374
|
}
|
@@ -325,7 +402,7 @@ module Glimmer
|
|
325
402
|
background color(:widget_background)
|
326
403
|
editable false
|
327
404
|
caret nil
|
328
|
-
text bind(
|
405
|
+
text bind(Dir.local_dir, 'selected_child.path')
|
329
406
|
on_mouse_up {
|
330
407
|
@file_path_label.swt_widget.selectAll
|
331
408
|
}
|
@@ -343,7 +420,7 @@ module Glimmer
|
|
343
420
|
layout_data(:fill, :fill, true, false) {
|
344
421
|
minimum_width 400
|
345
422
|
}
|
346
|
-
text bind(
|
423
|
+
text bind(Dir.local_dir, 'selected_child.line_number', on_read: :to_s, on_write: :to_i)
|
347
424
|
on_key_pressed { |key_event|
|
348
425
|
if key_event.keyCode == swt(:cr)
|
349
426
|
@text_editor&.text_widget&.setFocus
|
@@ -361,17 +438,17 @@ module Glimmer
|
|
361
438
|
text 'Find:'
|
362
439
|
}
|
363
440
|
@find_text = text {
|
364
|
-
layout_data(:fill, :
|
441
|
+
layout_data(:fill, :center, true, false) {
|
365
442
|
minimum_width 400
|
366
443
|
}
|
367
|
-
text bind(
|
444
|
+
text bind(Dir.local_dir, 'selected_child.find_text')
|
368
445
|
on_key_pressed { |key_event|
|
369
446
|
if key_event.stateMask == swt(COMMAND_KEY) && key_event.keyCode == swt(:cr)
|
370
447
|
Dir.local_dir.selected_child.case_sensitive = !Dir.local_dir.selected_child.case_sensitive
|
371
|
-
|
448
|
+
Dir.local_dir.selected_child&.find_next
|
372
449
|
end
|
373
450
|
if key_event.keyCode == swt(:cr)
|
374
|
-
|
451
|
+
Dir.local_dir.selected_child&.find_next
|
375
452
|
end
|
376
453
|
}
|
377
454
|
}
|
@@ -381,7 +458,7 @@ module Glimmer
|
|
381
458
|
selection bind(Dir.local_dir, 'selected_child.case_sensitive')
|
382
459
|
on_key_pressed { |key_event|
|
383
460
|
if key_event.keyCode == swt(:cr)
|
384
|
-
|
461
|
+
Dir.local_dir.selected_child&.find_next
|
385
462
|
end
|
386
463
|
}
|
387
464
|
}
|
@@ -399,43 +476,80 @@ module Glimmer
|
|
399
476
|
layout_data(:fill, :fill, true, false) {
|
400
477
|
minimum_width 300
|
401
478
|
}
|
402
|
-
text bind(
|
479
|
+
text bind(Dir.local_dir, 'selected_child.replace_text')
|
403
480
|
on_focus_gained {
|
404
|
-
|
481
|
+
Dir.local_dir.selected_child&.ensure_find_next
|
405
482
|
}
|
406
483
|
on_key_pressed { |key_event|
|
407
484
|
if key_event.keyCode == swt(:cr)
|
408
|
-
if
|
409
|
-
Command.do(
|
485
|
+
if Dir.local_dir.selected_child
|
486
|
+
Command.do(Dir.local_dir.selected_child, :replace_next!)
|
410
487
|
end
|
411
488
|
end
|
412
489
|
}
|
413
490
|
}
|
414
491
|
label
|
415
492
|
}
|
416
|
-
@
|
417
|
-
layout_data(:fill, :fill, true, true)
|
493
|
+
@tab_folder_sash_form = sash_form {
|
494
|
+
layout_data(:fill, :fill, true, true) {
|
495
|
+
width_hint 640
|
496
|
+
height_hint 480
|
497
|
+
}
|
498
|
+
sash_width 10
|
499
|
+
@tab_folder = tab_folder {
|
500
|
+
drag_source(DND::DROP_COPY) {
|
501
|
+
transfer [TextTransfer.getInstance].to_java(Transfer)
|
502
|
+
event_data = nil
|
503
|
+
on_drag_start {|event|
|
504
|
+
Gladiator.drag = true
|
505
|
+
tab_folder = event.widget.getControl
|
506
|
+
tab_item = tab_folder.getItem(Point.new(event.x, event.y))
|
507
|
+
event_data = tab_item.getData('file_path')
|
508
|
+
}
|
509
|
+
on_drag_set_data { |event|
|
510
|
+
event.data = event_data
|
511
|
+
}
|
512
|
+
}
|
513
|
+
}
|
514
|
+
@tab_folder.swt_widget.setData('proxy', @tab_folder)
|
418
515
|
}
|
419
516
|
}
|
420
517
|
}
|
421
518
|
}
|
422
|
-
|
519
|
+
|
520
|
+
def load_config_ignore_paths
|
521
|
+
# TODO eliminate duplication with load_config
|
522
|
+
if ::File.exists?(@config_file_path)
|
523
|
+
config_yaml = ::File.read(@config_file_path)
|
524
|
+
return if config_yaml.to_s.strip.empty?
|
525
|
+
@config = YAML.load(config_yaml)
|
526
|
+
Dir.local_dir.ignore_paths = @config[:ignore_paths] if @config[:ignore_paths]
|
527
|
+
Dir.local_dir.ignore_paths ||= ['packages', 'tmp']
|
528
|
+
else
|
529
|
+
@loaded_config = true
|
530
|
+
end
|
531
|
+
end
|
532
|
+
|
423
533
|
def load_config
|
424
534
|
if ::File.exists?(@config_file_path)
|
425
535
|
config_yaml = ::File.read(@config_file_path)
|
426
536
|
return if config_yaml.to_s.strip.empty?
|
427
537
|
@config = YAML.load(config_yaml)
|
428
|
-
@config[:
|
429
|
-
|
538
|
+
Dir.local_dir.ignore_paths = @config[:ignore_paths] if @config[:ignore_paths]
|
539
|
+
Dir.local_dir.ignore_paths ||= ['packages', 'tmp']
|
540
|
+
open_file_paths1 = @config[:open_file_paths1] || @config[:open_file_paths]
|
541
|
+
open_file_paths2 = @config[:open_file_paths2]
|
542
|
+
open_file_paths1.to_a.each do |file_path|
|
543
|
+
Dir.local_dir.selected_child_path = file_path
|
430
544
|
end
|
431
|
-
Gladiator
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
545
|
+
Gladiator.drag = true
|
546
|
+
open_file_paths2.to_a.each do |file_path|
|
547
|
+
Dir.local_dir.selected_child_path = file_path
|
548
|
+
end
|
549
|
+
Gladiator.drag = false
|
550
|
+
Dir.local_dir.selected_child_path = @config[:selected_child_path] if @config[:selected_child_path]
|
551
|
+
Dir.local_dir.selected_child&.caret_position = Dir.local_dir.selected_child&.caret_position_for_caret_position_start_of_line(@config[:caret_position].to_i) if @config[:caret_position]
|
552
|
+
Dir.local_dir.selected_child&.top_index = @config[:top_index].to_i if @config[:top_index]
|
439
553
|
else
|
440
554
|
@loaded_config = true
|
441
555
|
end
|
@@ -443,8 +557,12 @@ module Glimmer
|
|
443
557
|
|
444
558
|
def save_config
|
445
559
|
return unless @loaded_config
|
446
|
-
child =
|
560
|
+
child = Dir.local_dir.selected_child
|
447
561
|
return if child.nil?
|
562
|
+
tab_folder1 = @tab_folder1 || @tab_folder
|
563
|
+
tab_folder2 = @tab_folder2
|
564
|
+
open_file_paths1 = tab_folder1&.swt_widget&.items&.to_a.map {|i| i.get_data('file_path')}
|
565
|
+
open_file_paths2 = tab_folder2&.swt_widget&.items&.to_a.map {|i| i.get_data('file_path')}
|
448
566
|
@config = {
|
449
567
|
selected_child_path: child.path,
|
450
568
|
caret_position: child.caret_position,
|
@@ -453,7 +571,9 @@ module Glimmer
|
|
453
571
|
shell_height: swt_widget&.getBounds&.height,
|
454
572
|
shell_x: swt_widget&.getBounds&.x,
|
455
573
|
shell_y: swt_widget&.getBounds&.y,
|
456
|
-
|
574
|
+
open_file_paths1: open_file_paths1,
|
575
|
+
open_file_paths2: open_file_paths2,
|
576
|
+
ignore_paths: Dir.local_dir.ignore_paths
|
457
577
|
}
|
458
578
|
config_yaml = YAML.dump(@config)
|
459
579
|
::File.write(@config_file_path, config_yaml) unless config_yaml.to_s.empty?
|
@@ -461,12 +581,31 @@ module Glimmer
|
|
461
581
|
puts e.full_message
|
462
582
|
end
|
463
583
|
|
584
|
+
def close_tab_folder
|
585
|
+
if @tab_folder2 && !selected_tab_item
|
586
|
+
if @tab_folder == @tab_folder2
|
587
|
+
@tab_folder2.swt_widget.dispose
|
588
|
+
@tab_folder = @tab_folder1
|
589
|
+
else
|
590
|
+
@tab_folder1.swt_widget.dispose
|
591
|
+
@tab_folder = @tab_folder1 = @tab_folder2
|
592
|
+
end
|
593
|
+
@tab_folder2 = nil
|
594
|
+
|
595
|
+
@tab_item = @tab_folder.swt_widget.getData('selected_tab_item')
|
596
|
+
@text_editor = @tab_item.swt_tab_item.getData('text_editor')
|
597
|
+
Dir.local_dir.selected_child = @tab_item.swt_tab_item.getData('file')
|
598
|
+
|
599
|
+
body_root.pack_same_size
|
600
|
+
end
|
601
|
+
end
|
602
|
+
|
464
603
|
def selected_tab_item
|
465
|
-
@tab_folder.swt_widget.getItems.detect { |ti| ti.getData('file_path') ==
|
604
|
+
@tab_folder.swt_widget.getItems.detect { |ti| ti.getData('file_path') == Dir.local_dir.selected_child&.path }
|
466
605
|
end
|
467
606
|
|
468
607
|
def other_tab_items
|
469
|
-
@tab_folder.swt_widget.getItems.reject { |ti| ti.getData('file_path') ==
|
608
|
+
@tab_folder.swt_widget.getItems.reject { |ti| ti.getData('file_path') == Dir.local_dir.selected_child&.path }
|
470
609
|
end
|
471
610
|
|
472
611
|
def extract_tree_item_path(tree_item)
|
@@ -479,8 +618,8 @@ module Glimmer
|
|
479
618
|
end
|
480
619
|
|
481
620
|
def select_tree_item
|
482
|
-
return unless
|
483
|
-
tree_items_to_select = @tree.depth_first_search { |ti| ti.getData.path ==
|
621
|
+
return unless Dir.local_dir.selected_child&.name
|
622
|
+
tree_items_to_select = @tree.depth_first_search { |ti| ti.getData.path == Dir.local_dir.selected_child.path }
|
484
623
|
@tree.swt_widget.setSelection(tree_items_to_select)
|
485
624
|
end
|
486
625
|
|
@@ -497,6 +636,8 @@ module Glimmer
|
|
497
636
|
# if file.is_a?(::File)
|
498
637
|
# close tab
|
499
638
|
# end
|
639
|
+
rescue => e
|
640
|
+
puts e.full_message
|
500
641
|
end
|
501
642
|
|
502
643
|
def rename_selected_tree_item
|
@@ -532,6 +673,7 @@ module Glimmer
|
|
532
673
|
end
|
533
674
|
new_file_path = ::File.expand_path(::File.join(directory_path, 'new_file'))
|
534
675
|
FileUtils.touch(new_file_path)
|
676
|
+
# TODO look into refreshing only the parent directory to avoid slowdown
|
535
677
|
Dir.local_dir.refresh(async: false, force: true)
|
536
678
|
new_tree_item = @tree.depth_first_search {|ti| ti.getData.path == new_file_path}.first
|
537
679
|
@tree.swt_widget.showItem(new_tree_item)
|
@@ -5,10 +5,11 @@ module Glimmer
|
|
5
5
|
|
6
6
|
options :file
|
7
7
|
|
8
|
-
attr_reader :text_widget
|
8
|
+
attr_reader :text_proxy, :text_widget
|
9
9
|
|
10
10
|
after_body {
|
11
11
|
@text_widget = @text.swt_widget
|
12
|
+
@text_proxy = @text
|
12
13
|
}
|
13
14
|
|
14
15
|
body {
|
@@ -41,6 +42,19 @@ module Glimmer
|
|
41
42
|
selection bind(file, 'selection')
|
42
43
|
selection_count bind(file, 'selection_count')
|
43
44
|
top_index bind(file, 'top_index')
|
45
|
+
drop_target(DND::DROP_COPY) {
|
46
|
+
transfer [TextTransfer.getInstance].to_java(Transfer)
|
47
|
+
on_drag_enter { |event|
|
48
|
+
event.detail = DND::DROP_COPY
|
49
|
+
}
|
50
|
+
on_drop { |event|
|
51
|
+
Gladiator.drag_and_drop = true
|
52
|
+
Dir.local_dir.selected_child = nil
|
53
|
+
Dir.local_dir.selected_child_path = event.data
|
54
|
+
Gladiator.drag = false
|
55
|
+
}
|
56
|
+
}
|
57
|
+
|
44
58
|
on_focus_lost {
|
45
59
|
file&.write_dirty_content
|
46
60
|
}
|
metadata
CHANGED
@@ -1,35 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glimmer-cs-gladiator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Maleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
15
15
|
requirements:
|
16
16
|
- - ">="
|
17
17
|
- !ruby/object:Gem::Version
|
18
|
-
version:
|
18
|
+
version: 4.17.2.0
|
19
19
|
- - "<"
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: 5.0.0.0
|
22
22
|
name: glimmer-dsl-swt
|
23
|
-
type: :runtime
|
24
23
|
prerelease: false
|
24
|
+
type: :runtime
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
29
|
+
version: 4.17.2.0
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
32
|
+
version: 5.0.0.0
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
requirement: !ruby/object:Gem::Requirement
|
35
35
|
requirements:
|
@@ -37,8 +37,8 @@ dependencies:
|
|
37
37
|
- !ruby/object:Gem::Version
|
38
38
|
version: 1.1.1
|
39
39
|
name: filewatcher
|
40
|
-
type: :runtime
|
41
40
|
prerelease: false
|
41
|
+
type: :runtime
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
44
|
- - "~>"
|
@@ -51,8 +51,8 @@ dependencies:
|
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: 1.3.4
|
53
53
|
name: clipboard
|
54
|
-
type: :runtime
|
55
54
|
prerelease: false
|
55
|
+
type: :runtime
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
58
|
- - "~>"
|
@@ -65,8 +65,8 @@ dependencies:
|
|
65
65
|
- !ruby/object:Gem::Version
|
66
66
|
version: 3.5.0
|
67
67
|
name: rspec
|
68
|
-
type: :development
|
69
68
|
prerelease: false
|
69
|
+
type: :development
|
70
70
|
version_requirements: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
72
|
- - "~>"
|
@@ -79,8 +79,8 @@ dependencies:
|
|
79
79
|
- !ruby/object:Gem::Version
|
80
80
|
version: 2.3.9
|
81
81
|
name: jeweler
|
82
|
-
type: :development
|
83
82
|
prerelease: false
|
83
|
+
type: :development
|
84
84
|
version_requirements: !ruby/object:Gem::Requirement
|
85
85
|
requirements:
|
86
86
|
- - '='
|
@@ -93,27 +93,13 @@ dependencies:
|
|
93
93
|
- !ruby/object:Gem::Version
|
94
94
|
version: '0'
|
95
95
|
name: simplecov
|
96
|
-
type: :development
|
97
96
|
prerelease: false
|
97
|
+
type: :development
|
98
98
|
version_requirements: !ruby/object:Gem::Requirement
|
99
99
|
requirements:
|
100
100
|
- - ">="
|
101
101
|
- !ruby/object:Gem::Version
|
102
102
|
version: '0'
|
103
|
-
- !ruby/object:Gem::Dependency
|
104
|
-
requirement: !ruby/object:Gem::Requirement
|
105
|
-
requirements:
|
106
|
-
- - "~>"
|
107
|
-
- !ruby/object:Gem::Version
|
108
|
-
version: 0.8.1
|
109
|
-
name: puts_debuggerer
|
110
|
-
type: :development
|
111
|
-
prerelease: false
|
112
|
-
version_requirements: !ruby/object:Gem::Requirement
|
113
|
-
requirements:
|
114
|
-
- - "~>"
|
115
|
-
- !ruby/object:Gem::Version
|
116
|
-
version: 0.8.1
|
117
103
|
description: Gladiator (short for Glimmer Editor) is a Glimmer sample project under
|
118
104
|
on-going development. It is not intended to be a full-fledged editor by any means,
|
119
105
|
yet mostly a fun educational exercise in using Glimmer to build a text editor. Gladiator
|
@@ -158,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
158
144
|
- !ruby/object:Gem::Version
|
159
145
|
version: '0'
|
160
146
|
requirements: []
|
161
|
-
rubygems_version: 3.
|
147
|
+
rubygems_version: 3.1.4
|
162
148
|
signing_key:
|
163
149
|
specification_version: 4
|
164
150
|
summary: Gladiator (Glimmer Editor) - Glimmer Custom Shell
|