glimmer-cs-gladiator 0.2.4 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -9
- data/VERSION +1 -1
- data/lib/glimmer-cs-gladiator.rb +23 -0
- data/lib/models/glimmer/gladiator/dir.rb +9 -3
- data/lib/views/glimmer/gladiator.rb +25 -8
- metadata +13 -13
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,10 +1,10 @@
|
|
1
|
-
# <img src='https://raw.githubusercontent.com/AndyObtiva/glimmer-cs-gladiator/master/images/glimmer-cs-gladiator-logo.svg' height=85 /> Gladiator 0.
|
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#custom-shell-gem)
|
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)
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/glimmer-cs-gladiator.svg)](http://badge.fury.io/rb/glimmer-cs-gladiator)
|
4
4
|
|
5
5
|
![Gladiator](images/glimmer-gladiator.png)
|
6
6
|
|
7
|
-
Gladiator (short for Glimmer Editor) is a [Glimmer](https://github.com/AndyObtiva/glimmer) sample project under on-going development that demonstrates how to build a text editor in [Glimmer](https://github.com/AndyObtiva/glimmer) (
|
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
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
9
|
Gladiator is also a personal tool for shaping an editor exactly the way I like, with all the keyboard shortcuts I prefer.
|
10
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.
|
@@ -39,9 +39,9 @@ Gladiator currently supports the following text editing features (including keyb
|
|
39
39
|
|
40
40
|
## Pre-requisites
|
41
41
|
|
42
|
-
- [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer) (
|
43
|
-
- [JRuby](https://www.jruby.org/download): Same version required by [Glimmer](https://github.com/AndyObtiva/glimmer)
|
44
|
-
- [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)
|
45
45
|
|
46
46
|
## Setup Instructions
|
47
47
|
|
@@ -99,7 +99,7 @@ To reuse Gladiator as a Glimmer Custom Shell inside another Glimmer application,
|
|
99
99
|
following to the application's `Gemfile`:
|
100
100
|
|
101
101
|
```
|
102
|
-
gem 'glimmer-cs-gladiator', '~> 0.
|
102
|
+
gem 'glimmer-cs-gladiator', '~> 0.3.0'
|
103
103
|
```
|
104
104
|
|
105
105
|
Run:
|
@@ -108,7 +108,7 @@ Run:
|
|
108
108
|
jruby -S bundle
|
109
109
|
```
|
110
110
|
|
111
|
-
And, then instantiate the Gladiator [custom shell](https://github.com/AndyObtiva/glimmer#custom-shells) in your [Glimmer](https://github.com/AndyObtiva/glimmer) application via the `gladiator` keyword assuming you already have `include Glimmer` in your class, module, or main object.
|
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.
|
112
112
|
|
113
113
|
## Env Var Options
|
114
114
|
|
@@ -132,6 +132,7 @@ It currently remembers:
|
|
132
132
|
- Caret position
|
133
133
|
- Top line position
|
134
134
|
- Opened tabs
|
135
|
+
- Ignore Paths
|
135
136
|
|
136
137
|
## Gotcha
|
137
138
|
|
@@ -164,6 +165,6 @@ Copyright (c) 2020 Andy Maleh. See [LICENSE.txt](LICENSE.txt) for further detail
|
|
164
165
|
|
165
166
|
--
|
166
167
|
|
167
|
-
[<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](https://github.com/AndyObtiva/glimmer) (
|
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)
|
168
169
|
|
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
@@ -4,3 +4,26 @@ require 'filewatcher'
|
|
4
4
|
require 'clipboard'
|
5
5
|
require 'puts_debuggerer'
|
6
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
|
@@ -11,7 +11,7 @@ module Glimmer
|
|
11
11
|
def local_dir
|
12
12
|
unless @local_dir
|
13
13
|
@local_dir = new(ENV['LOCAL_DIR'] || '.', true)
|
14
|
-
|
14
|
+
# @local_dir.refresh
|
15
15
|
@filewatcher = Filewatcher.new(@local_dir.path)
|
16
16
|
@thread = Thread.new(@filewatcher) do |fw|
|
17
17
|
fw.watch do |filename, event|
|
@@ -26,7 +26,7 @@ module Glimmer
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
attr_accessor :selected_child, :filter, :children, :filtered_path_options, :filtered_path, :display_path
|
29
|
+
attr_accessor :selected_child, :filter, :children, :filtered_path_options, :filtered_path, :display_path, :ignore_paths
|
30
30
|
attr_reader :name, :parent, :path, :is_local_dir
|
31
31
|
attr_writer :all_children
|
32
32
|
|
@@ -34,6 +34,7 @@ module Glimmer
|
|
34
34
|
@is_local_dir = is_local_dir
|
35
35
|
self.path = ::File.expand_path(path)
|
36
36
|
@name = ::File.basename(::File.expand_path(path))
|
37
|
+
@ignore_paths = ['packages', 'tmp']
|
37
38
|
self.filtered_path_options = []
|
38
39
|
end
|
39
40
|
|
@@ -59,7 +60,12 @@ module Glimmer
|
|
59
60
|
end
|
60
61
|
|
61
62
|
def retrieve_children
|
62
|
-
@children = ::Dir.glob(::File.join(@path, '*')).
|
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|
|
63
69
|
::File.file?(p) ? Gladiator::File.new(p) : Gladiator::Dir.new(p)
|
64
70
|
end.sort_by do |c|
|
65
71
|
c.path.to_s.downcase
|
@@ -150,7 +150,8 @@ module Glimmer
|
|
150
150
|
local_dir = ENV['LOCAL_DIR'] || '.'
|
151
151
|
@config_file_path = ::File.join(local_dir, '.gladiator')
|
152
152
|
@config = {}
|
153
|
-
|
153
|
+
load_config_ignore_paths
|
154
|
+
# Dir.local_dir.all_children # pre-caches children
|
154
155
|
}
|
155
156
|
|
156
157
|
## Uncomment after_body block to setup observers for widgets in body
|
@@ -236,7 +237,12 @@ module Glimmer
|
|
236
237
|
text "Gladiator - #{::File.expand_path(Dir.local_dir.path)}"
|
237
238
|
minimum_size 520, 250
|
238
239
|
size 1440, 900
|
239
|
-
grid_layout
|
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
|
+
}
|
240
246
|
on_swt_close {
|
241
247
|
Dir.local_dir.selected_child&.write_dirty_content
|
242
248
|
}
|
@@ -432,7 +438,7 @@ module Glimmer
|
|
432
438
|
text 'Find:'
|
433
439
|
}
|
434
440
|
@find_text = text {
|
435
|
-
layout_data(:fill, :
|
441
|
+
layout_data(:fill, :center, true, false) {
|
436
442
|
minimum_width 400
|
437
443
|
}
|
438
444
|
text bind(Dir.local_dir, 'selected_child.find_text')
|
@@ -511,11 +517,26 @@ module Glimmer
|
|
511
517
|
}
|
512
518
|
}
|
513
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
|
+
|
514
533
|
def load_config
|
515
534
|
if ::File.exists?(@config_file_path)
|
516
535
|
config_yaml = ::File.read(@config_file_path)
|
517
536
|
return if config_yaml.to_s.strip.empty?
|
518
537
|
@config = YAML.load(config_yaml)
|
538
|
+
Dir.local_dir.ignore_paths = @config[:ignore_paths] if @config[:ignore_paths]
|
539
|
+
Dir.local_dir.ignore_paths ||= ['packages', 'tmp']
|
519
540
|
open_file_paths1 = @config[:open_file_paths1] || @config[:open_file_paths]
|
520
541
|
open_file_paths2 = @config[:open_file_paths2]
|
521
542
|
open_file_paths1.to_a.each do |file_path|
|
@@ -529,11 +550,6 @@ module Glimmer
|
|
529
550
|
Dir.local_dir.selected_child_path = @config[:selected_child_path] if @config[:selected_child_path]
|
530
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]
|
531
552
|
Dir.local_dir.selected_child&.top_index = @config[:top_index].to_i if @config[:top_index]
|
532
|
-
body_root.on_swt_show {
|
533
|
-
swt_widget.setSize(@config[:shell_width], @config[:shell_height]) if @config[:shell_width] && @config[:shell_height]
|
534
|
-
swt_widget.setLocation(@config[:shell_x], @config[:shell_y]) if @config[:shell_x] && @config[:shell_y]
|
535
|
-
@loaded_config = true
|
536
|
-
}
|
537
553
|
else
|
538
554
|
@loaded_config = true
|
539
555
|
end
|
@@ -557,6 +573,7 @@ module Glimmer
|
|
557
573
|
shell_y: swt_widget&.getBounds&.y,
|
558
574
|
open_file_paths1: open_file_paths1,
|
559
575
|
open_file_paths2: open_file_paths2,
|
576
|
+
ignore_paths: Dir.local_dir.ignore_paths
|
560
577
|
}
|
561
578
|
config_yaml = YAML.dump(@config)
|
562
579
|
::File.write(@config_file_path, config_yaml) unless config_yaml.to_s.empty?
|
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,8 +93,8 @@ 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
|
- - ">="
|
@@ -144,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
144
144
|
- !ruby/object:Gem::Version
|
145
145
|
version: '0'
|
146
146
|
requirements: []
|
147
|
-
rubygems_version: 3.
|
147
|
+
rubygems_version: 3.1.4
|
148
148
|
signing_key:
|
149
149
|
specification_version: 4
|
150
150
|
summary: Gladiator (Glimmer Editor) - Glimmer Custom Shell
|