glimmer-cs-gladiator 0.8.1 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +43 -0
- data/LICENSE.txt +20 -20
- data/README.md +65 -31
- data/VERSION +1 -1
- data/bin/gladiator +31 -34
- data/bin/gladiator-setup +80 -80
- data/bin/glimmer-cs-gladiator +22 -22
- data/glimmer-cs-gladiator.gemspec +17 -22
- data/images/glimmer-cs-gladiator-logo.png +0 -0
- data/lib/glimmer-cs-gladiator/launch.rb +6 -6
- data/lib/glimmer-cs-gladiator.rb +30 -30
- data/lib/models/glimmer/gladiator/command.rb +112 -112
- data/lib/models/glimmer/gladiator/dir.rb +17 -4
- data/lib/models/glimmer/gladiator/file.rb +729 -662
- data/lib/views/glimmer/gladiator/file_edit_menu.rb +67 -0
- data/lib/views/glimmer/gladiator/file_explorer_tree.rb +244 -244
- data/lib/views/glimmer/gladiator/file_lookup_list.rb +63 -64
- data/lib/views/glimmer/gladiator/gladiator_menu_bar.rb +35 -8
- data/lib/views/glimmer/gladiator/progress_shell.rb +29 -31
- data/lib/views/glimmer/gladiator/text_editor.rb +11 -0
- data/lib/views/glimmer/gladiator.rb +159 -138
- metadata +29 -20
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: glimmer-cs-gladiator 0.
|
5
|
+
# stub: glimmer-cs-gladiator 0.9.2 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "glimmer-cs-gladiator".freeze
|
9
|
-
s.version = "0.
|
9
|
+
s.version = "0.9.2"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib".freeze]
|
13
13
|
s.authors = ["Andy Maleh".freeze]
|
14
|
-
s.date = "2021-
|
14
|
+
s.date = "2021-12-10"
|
15
15
|
s.description = "Gladiator (short for Glimmer Editor) is a Glimmer sample project under on-going development. It is not intended to be a full-fledged editor by any means, yet mostly a fun educational exercise in using Glimmer to build a text editor. Gladiator is also a personal tool for shaping an editor exactly the way I like. I leave building truly professional text editors to software tooling experts who would hopefully use Glimmer one day.".freeze
|
16
16
|
s.email = "andy.am@gmail.com".freeze
|
17
17
|
s.executables = ["glimmer-cs-gladiator".freeze, "gladiator".freeze, "gladiator-setup".freeze]
|
@@ -36,6 +36,7 @@ Gem::Specification.new do |s|
|
|
36
36
|
"lib/models/glimmer/gladiator/dir.rb",
|
37
37
|
"lib/models/glimmer/gladiator/file.rb",
|
38
38
|
"lib/views/glimmer/gladiator.rb",
|
39
|
+
"lib/views/glimmer/gladiator/file_edit_menu.rb",
|
39
40
|
"lib/views/glimmer/gladiator/file_explorer_tree.rb",
|
40
41
|
"lib/views/glimmer/gladiator/file_lookup_list.rb",
|
41
42
|
"lib/views/glimmer/gladiator/gladiator_menu_bar.rb",
|
@@ -45,36 +46,30 @@ Gem::Specification.new do |s|
|
|
45
46
|
s.homepage = "http://github.com/AndyObtiva/glimmer-cs-gladiator".freeze
|
46
47
|
s.licenses = ["MIT".freeze]
|
47
48
|
s.post_install_message = "\nTo make the gladiator command available system-wide (especially with RVM), make sure you run this command with jruby in path: gladiator-setup\n\n".freeze
|
48
|
-
s.rubygems_version = "3.
|
49
|
+
s.rubygems_version = "3.1.6".freeze
|
49
50
|
s.summary = "Gladiator (Glimmer Editor) - Glimmer Custom Shell - Text Editor Built in Ruby".freeze
|
50
51
|
|
51
52
|
if s.respond_to? :specification_version then
|
52
53
|
s.specification_version = 4
|
54
|
+
end
|
53
55
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
s.add_dependency(%q<glimmer-dsl-swt>.freeze, [">= 4.18.4.3", "< 5.0.0.0"])
|
64
|
-
s.add_dependency(%q<filewatcher>.freeze, ["~> 1.1.1"])
|
65
|
-
s.add_dependency(%q<clipboard>.freeze, ["~> 1.3.5"])
|
66
|
-
s.add_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
|
67
|
-
s.add_dependency(%q<jeweler>.freeze, ["= 2.3.9"])
|
68
|
-
s.add_dependency(%q<warbler>.freeze, ["= 2.0.5"])
|
69
|
-
s.add_dependency(%q<simplecov>.freeze, [">= 0"])
|
70
|
-
end
|
56
|
+
if s.respond_to? :add_runtime_dependency then
|
57
|
+
s.add_runtime_dependency(%q<glimmer-dsl-swt>.freeze, ["~> 4.20.16.0"])
|
58
|
+
s.add_runtime_dependency(%q<filewatcher>.freeze, ["~> 1.1.1"])
|
59
|
+
s.add_runtime_dependency(%q<clipboard>.freeze, ["~> 1.3.5"])
|
60
|
+
s.add_development_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
|
61
|
+
s.add_development_dependency(%q<jeweler>.freeze, ["= 2.3.9"])
|
62
|
+
s.add_development_dependency(%q<warbler>.freeze, ["= 2.0.5"])
|
63
|
+
s.add_development_dependency(%q<jruby-jars>.freeze, ["= 9.2.19.0"])
|
64
|
+
s.add_development_dependency(%q<simplecov>.freeze, [">= 0"])
|
71
65
|
else
|
72
|
-
s.add_dependency(%q<glimmer-dsl-swt>.freeze, ["
|
66
|
+
s.add_dependency(%q<glimmer-dsl-swt>.freeze, ["~> 4.20.16.0"])
|
73
67
|
s.add_dependency(%q<filewatcher>.freeze, ["~> 1.1.1"])
|
74
68
|
s.add_dependency(%q<clipboard>.freeze, ["~> 1.3.5"])
|
75
69
|
s.add_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
|
76
70
|
s.add_dependency(%q<jeweler>.freeze, ["= 2.3.9"])
|
77
71
|
s.add_dependency(%q<warbler>.freeze, ["= 2.0.5"])
|
72
|
+
s.add_dependency(%q<jruby-jars>.freeze, ["= 9.2.19.0"])
|
78
73
|
s.add_dependency(%q<simplecov>.freeze, [">= 0"])
|
79
74
|
end
|
80
75
|
end
|
Binary file
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require_relative '../glimmer-cs-gladiator'
|
2
|
-
|
3
|
-
include Glimmer
|
4
|
-
|
5
|
-
local_dir = ENV['LOCAL_DIR'] || '.'
|
6
|
-
gladiator(project_dir_path: local_dir).open
|
1
|
+
require_relative '../glimmer-cs-gladiator'
|
2
|
+
|
3
|
+
include Glimmer
|
4
|
+
|
5
|
+
local_dir = ENV['LOCAL_DIR'] || '.'
|
6
|
+
gladiator(project_dir_path: local_dir).open
|
data/lib/glimmer-cs-gladiator.rb
CHANGED
@@ -1,30 +1,30 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.expand_path('..', __FILE__))
|
2
|
-
|
3
|
-
require 'glimmer-dsl-swt'
|
4
|
-
require 'filewatcher'
|
5
|
-
require 'clipboard'
|
6
|
-
require 'puts_debuggerer'
|
7
|
-
require 'views/glimmer/gladiator'
|
8
|
-
|
9
|
-
# Custom Composite Initializer (avoid default margins)
|
10
|
-
Glimmer::SWT::WidgetProxy::DEFAULT_INITIALIZERS['composite'] = lambda do |composite|
|
11
|
-
if composite.get_layout.nil?
|
12
|
-
layout = GridLayout.new
|
13
|
-
composite.layout = layout
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
# Custom LayoutProxy initialize method (avoid default margins)
|
18
|
-
module Glimmer
|
19
|
-
module SWT
|
20
|
-
class LayoutProxy
|
21
|
-
def initialize(underscored_layout_name, widget_proxy, args)
|
22
|
-
@underscored_layout_name = underscored_layout_name
|
23
|
-
@widget_proxy = widget_proxy
|
24
|
-
args = SWTProxy.constantify_args(args)
|
25
|
-
@swt_layout = self.class.swt_layout_class_for(underscored_layout_name).new(*args)
|
26
|
-
@widget_proxy.swt_widget.setLayout(@swt_layout)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
1
|
+
$LOAD_PATH.unshift(File.expand_path('..', __FILE__))
|
2
|
+
|
3
|
+
require 'glimmer-dsl-swt'
|
4
|
+
require 'filewatcher'
|
5
|
+
require 'clipboard'
|
6
|
+
require 'puts_debuggerer'
|
7
|
+
require 'views/glimmer/gladiator'
|
8
|
+
|
9
|
+
# Custom Composite Initializer (avoid default margins)
|
10
|
+
Glimmer::SWT::WidgetProxy::DEFAULT_INITIALIZERS['composite'] = lambda do |composite|
|
11
|
+
if composite.get_layout.nil?
|
12
|
+
layout = GridLayout.new
|
13
|
+
composite.layout = layout
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# Custom LayoutProxy initialize method (avoid default margins)
|
18
|
+
module Glimmer
|
19
|
+
module SWT
|
20
|
+
class LayoutProxy
|
21
|
+
def initialize(underscored_layout_name, widget_proxy, args)
|
22
|
+
@underscored_layout_name = underscored_layout_name
|
23
|
+
@widget_proxy = widget_proxy
|
24
|
+
args = SWTProxy.constantify_args(args)
|
25
|
+
@swt_layout = self.class.swt_layout_class_for(underscored_layout_name).new(*args)
|
26
|
+
@widget_proxy.swt_widget.setLayout(@swt_layout)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -1,112 +1,112 @@
|
|
1
|
-
module Glimmer
|
2
|
-
class Gladiator
|
3
|
-
class Command
|
4
|
-
include Glimmer
|
5
|
-
|
6
|
-
class << self
|
7
|
-
include Glimmer
|
8
|
-
|
9
|
-
def command_history
|
10
|
-
@command_history ||= {}
|
11
|
-
end
|
12
|
-
|
13
|
-
def command_history_for(file)
|
14
|
-
# keeping a first command to make redo support work by remembering next command after undoing all
|
15
|
-
command_history[file] ||= [Command.new(file)]
|
16
|
-
end
|
17
|
-
|
18
|
-
def do(file, method = nil, *args, command: nil)
|
19
|
-
if command.nil?
|
20
|
-
command ||= Command.new(file, method, *args)
|
21
|
-
command.previous_command = command_history_for(file).last
|
22
|
-
unless command_history_for(file).last.method == :change_content! && method == :change_content!
|
23
|
-
command_history_for(file).last.next_command = command
|
24
|
-
end
|
25
|
-
command.do
|
26
|
-
command_history_for(file) << command unless command_history_for(file).last.method == :change_content! && method == :change_content!
|
27
|
-
else
|
28
|
-
command_history_for(file) << command
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def undo(file)
|
33
|
-
return if command_history_for(file).size <= 1
|
34
|
-
command = command_history_for(file).pop
|
35
|
-
command&.undo
|
36
|
-
end
|
37
|
-
|
38
|
-
def redo(file)
|
39
|
-
command = command_history_for(file).last
|
40
|
-
command&.redo
|
41
|
-
end
|
42
|
-
|
43
|
-
def clear(file)
|
44
|
-
command_history[file] = [Command.new(file)]
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
attr_accessor :file, :method, :args, :previous_command, :next_command,
|
49
|
-
:file_dirty_content, :file_caret_position, :file_selection_count, :previous_file_dirty_content, :previous_file_caret_position, :previous_file_selection_count
|
50
|
-
|
51
|
-
def initialize(file, method = nil, *args)
|
52
|
-
@file = file
|
53
|
-
@method = method
|
54
|
-
@args = args
|
55
|
-
end
|
56
|
-
|
57
|
-
|
58
|
-
def native?
|
59
|
-
@method.nil?
|
60
|
-
end
|
61
|
-
|
62
|
-
def do
|
63
|
-
return if native?
|
64
|
-
backup
|
65
|
-
execute
|
66
|
-
end
|
67
|
-
|
68
|
-
def undo
|
69
|
-
return if native?
|
70
|
-
restore
|
71
|
-
end
|
72
|
-
|
73
|
-
def redo
|
74
|
-
return if next_command.nil?# || next_command.native?
|
75
|
-
@file.dirty_content = next_command.file_dirty_content.clone
|
76
|
-
@file.caret_position = next_command.file_caret_position
|
77
|
-
@file.selection_count = next_command.file_selection_count
|
78
|
-
Command.do(next_command.file, command: next_command)
|
79
|
-
end
|
80
|
-
|
81
|
-
def backup
|
82
|
-
@previous_file_dirty_content = @file.dirty_content.clone
|
83
|
-
@previous_file_caret_position = @file.caret_position
|
84
|
-
@previous_file_selection_count = @file.selection_count
|
85
|
-
if @method == :change_content!
|
86
|
-
@previous_file_caret_position = @file.last_caret_position
|
87
|
-
@previous_file_selection_count = @file.last_selection_count
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
def restore
|
92
|
-
@file.dirty_content = @previous_file_dirty_content.clone
|
93
|
-
@file.caret_position = @previous_file_caret_position
|
94
|
-
@file.selection_count = @previous_file_selection_count
|
95
|
-
end
|
96
|
-
|
97
|
-
def execute
|
98
|
-
@file.start_command
|
99
|
-
@file.send(@method, *@args)
|
100
|
-
@file.end_command
|
101
|
-
@file_dirty_content = @file.dirty_content.clone
|
102
|
-
@file_caret_position = @file.caret_position
|
103
|
-
@file_selection_count = @file.selection_count
|
104
|
-
if previous_command.method == :change_content! && @method == :change_content!
|
105
|
-
previous_command.file_dirty_content = @file_dirty_content
|
106
|
-
previous_command.file_caret_position = @file_caret_position
|
107
|
-
previous_command.file_selection_count = @file_selection_count
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
1
|
+
module Glimmer
|
2
|
+
class Gladiator
|
3
|
+
class Command
|
4
|
+
include Glimmer
|
5
|
+
|
6
|
+
class << self
|
7
|
+
include Glimmer
|
8
|
+
|
9
|
+
def command_history
|
10
|
+
@command_history ||= {}
|
11
|
+
end
|
12
|
+
|
13
|
+
def command_history_for(file)
|
14
|
+
# keeping a first command to make redo support work by remembering next command after undoing all
|
15
|
+
command_history[file] ||= [Command.new(file)]
|
16
|
+
end
|
17
|
+
|
18
|
+
def do(file, method = nil, *args, command: nil)
|
19
|
+
if command.nil?
|
20
|
+
command ||= Command.new(file, method, *args)
|
21
|
+
command.previous_command = command_history_for(file).last
|
22
|
+
unless command_history_for(file).last.method == :change_content! && method == :change_content!
|
23
|
+
command_history_for(file).last.next_command = command
|
24
|
+
end
|
25
|
+
command.do
|
26
|
+
command_history_for(file) << command unless command_history_for(file).last.method == :change_content! && method == :change_content!
|
27
|
+
else
|
28
|
+
command_history_for(file) << command
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def undo(file)
|
33
|
+
return if command_history_for(file).size <= 1
|
34
|
+
command = command_history_for(file).pop
|
35
|
+
command&.undo
|
36
|
+
end
|
37
|
+
|
38
|
+
def redo(file)
|
39
|
+
command = command_history_for(file).last
|
40
|
+
command&.redo
|
41
|
+
end
|
42
|
+
|
43
|
+
def clear(file)
|
44
|
+
command_history[file] = [Command.new(file)]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
attr_accessor :file, :method, :args, :previous_command, :next_command,
|
49
|
+
:file_dirty_content, :file_caret_position, :file_selection_count, :previous_file_dirty_content, :previous_file_caret_position, :previous_file_selection_count
|
50
|
+
|
51
|
+
def initialize(file, method = nil, *args)
|
52
|
+
@file = file
|
53
|
+
@method = method
|
54
|
+
@args = args
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
def native?
|
59
|
+
@method.nil?
|
60
|
+
end
|
61
|
+
|
62
|
+
def do
|
63
|
+
return if native?
|
64
|
+
backup
|
65
|
+
execute
|
66
|
+
end
|
67
|
+
|
68
|
+
def undo
|
69
|
+
return if native?
|
70
|
+
restore
|
71
|
+
end
|
72
|
+
|
73
|
+
def redo
|
74
|
+
return if next_command.nil?# || next_command.native?
|
75
|
+
@file.dirty_content = next_command.file_dirty_content.clone
|
76
|
+
@file.caret_position = next_command.file_caret_position
|
77
|
+
@file.selection_count = next_command.file_selection_count
|
78
|
+
Command.do(next_command.file, command: next_command)
|
79
|
+
end
|
80
|
+
|
81
|
+
def backup
|
82
|
+
@previous_file_dirty_content = @file.dirty_content.clone
|
83
|
+
@previous_file_caret_position = @file.caret_position
|
84
|
+
@previous_file_selection_count = @file.selection_count
|
85
|
+
if @method == :change_content!
|
86
|
+
@previous_file_caret_position = @file.last_caret_position
|
87
|
+
@previous_file_selection_count = @file.last_selection_count
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def restore
|
92
|
+
@file.dirty_content = @previous_file_dirty_content.clone
|
93
|
+
@file.caret_position = @previous_file_caret_position
|
94
|
+
@file.selection_count = @previous_file_selection_count
|
95
|
+
end
|
96
|
+
|
97
|
+
def execute
|
98
|
+
@file.start_command
|
99
|
+
@file.send(@method, *@args)
|
100
|
+
@file.end_command
|
101
|
+
@file_dirty_content = @file.dirty_content.clone
|
102
|
+
@file_caret_position = @file.caret_position
|
103
|
+
@file_selection_count = @file.selection_count
|
104
|
+
if previous_command.method == :change_content! && @method == :change_content!
|
105
|
+
previous_command.file_dirty_content = @file_dirty_content
|
106
|
+
previous_command.file_caret_position = @file_caret_position
|
107
|
+
previous_command.file_selection_count = @file_selection_count
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
@@ -6,7 +6,7 @@ module Glimmer
|
|
6
6
|
include Glimmer
|
7
7
|
include Glimmer::DataBinding::ObservableModel
|
8
8
|
|
9
|
-
IGNORE_PATHS = ['.gladiator', '.git', 'coverage', 'packages', 'node_modules', 'tmp', 'vendor', 'pkg', 'dist']
|
9
|
+
IGNORE_PATHS = ['.gladiator', '.gladiator-scratchpad', '.git', 'coverage', 'packages', 'node_modules', 'tmp', 'vendor', 'pkg', 'dist']
|
10
10
|
|
11
11
|
attr_accessor :selected_child, :filter, :children, :filtered_path_options, :filtered_path, :display_path, :ignore_paths
|
12
12
|
attr_reader :name, :parent, :path
|
@@ -16,7 +16,7 @@ module Glimmer
|
|
16
16
|
@project_dir = project_dir
|
17
17
|
if is_local_dir
|
18
18
|
@filewatcher = Filewatcher.new(path)
|
19
|
-
Thread.new(@filewatcher) do |fw|
|
19
|
+
@filewatcher_thread = Thread.new(@filewatcher) do |fw|
|
20
20
|
begin
|
21
21
|
fw.watch do |filename, event|
|
22
22
|
# TODO do fine grained processing of events for enhanced performance (e.g. dir refresh vs file change)
|
@@ -109,6 +109,19 @@ module Glimmer
|
|
109
109
|
def selected_child_path_history
|
110
110
|
@selected_child_path_history ||= []
|
111
111
|
end
|
112
|
+
|
113
|
+
def close
|
114
|
+
all_children_files.each(&:close)
|
115
|
+
stop_filewatcher
|
116
|
+
end
|
117
|
+
|
118
|
+
def stop_filewatcher
|
119
|
+
@filewatcher&.stop
|
120
|
+
@filewatcher_thread&.kill
|
121
|
+
@filewatcher_thread = nil
|
122
|
+
@filewatcher&.finalize
|
123
|
+
@filewatcher = nil
|
124
|
+
end
|
112
125
|
|
113
126
|
def pause_refresh
|
114
127
|
@refresh_paused = true
|
@@ -177,7 +190,8 @@ module Glimmer
|
|
177
190
|
# scratchpad scenario
|
178
191
|
if selected_path.empty? # Scratchpad
|
179
192
|
@selected_child&.write_dirty_content
|
180
|
-
|
193
|
+
@scratchpad = (self.selected_child = File.new('', project_dir)) if @scratchpad.nil? || @scratchpad.closed?
|
194
|
+
return @scratchpad
|
181
195
|
end
|
182
196
|
full_selected_path = selected_path.include?(project_dir.path) ? selected_path : ::File.join(project_dir.path, selected_path)
|
183
197
|
return if ::Dir.exist?(full_selected_path) ||
|
@@ -188,7 +202,6 @@ module Glimmer
|
|
188
202
|
new_child = find_child_file(selected_path)
|
189
203
|
begin
|
190
204
|
unless new_child.dirty_content.nil?
|
191
|
-
self.selected_child&.stop_filewatcher
|
192
205
|
selected_child_path_history << new_child.path if new_child && !selected_child_path_history.include?(new_child.path)
|
193
206
|
self.selected_child = new_child
|
194
207
|
self.selected_child.start_filewatcher
|