glimmer-cs-gladiator 0.8.2 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +41 -0
- data/LICENSE.txt +20 -20
- data/README.md +102 -52
- 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 -24
- data/images/glimmer-cs-gladiator-logo.png +0 -0
- data/lib/glimmer-cs-gladiator/launch.rb +27 -6
- data/lib/glimmer-cs-gladiator.rb +30 -30
- data/lib/models/glimmer/gladiator/command.rb +21 -0
- data/lib/models/glimmer/gladiator/dir.rb +40 -6
- data/lib/models/glimmer/gladiator/file.rb +103 -42
- data/lib/views/glimmer/gladiator/file_edit_menu.rb +21 -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 +5 -5
- data/lib/views/glimmer/gladiator/progress_shell.rb +22 -0
- data/lib/views/glimmer/gladiator/text_editor.rb +3 -1
- data/lib/views/glimmer/gladiator.rb +135 -126
- metadata +28 -21
data/bin/glimmer-cs-gladiator
CHANGED
@@ -1,22 +1,22 @@
|
|
1
|
-
# Copyright (c) 2020-
|
2
|
-
#
|
3
|
-
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
# a copy of this software and associated documentation files (the
|
5
|
-
# "Software"), to deal in the Software without restriction, including
|
6
|
-
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
# the following conditions:
|
10
|
-
#
|
11
|
-
# The above copyright notice and this permission notice shall be
|
12
|
-
# included in all copies or substantial portions of the Software.
|
13
|
-
#
|
14
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
-
|
22
|
-
require_relative '../lib/glimmer-cs-gladiator/launch'
|
1
|
+
# Copyright (c) 2020-2022 Andy Maleh
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
require_relative '../lib/glimmer-cs-gladiator/launch'
|
@@ -1,22 +1,21 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in
|
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.3 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.3"
|
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 = "
|
14
|
+
s.date = "2022-01-29"
|
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]
|
18
18
|
s.extra_rdoc_files = [
|
19
|
-
"CHANGELOG.md",
|
20
19
|
"LICENSE.txt",
|
21
20
|
"README.md"
|
22
21
|
]
|
@@ -46,36 +45,30 @@ Gem::Specification.new do |s|
|
|
46
45
|
s.homepage = "http://github.com/AndyObtiva/glimmer-cs-gladiator".freeze
|
47
46
|
s.licenses = ["MIT".freeze]
|
48
47
|
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
|
49
|
-
s.rubygems_version = "3.
|
48
|
+
s.rubygems_version = "3.3.6".freeze
|
50
49
|
s.summary = "Gladiator (Glimmer Editor) - Glimmer Custom Shell - Text Editor Built in Ruby".freeze
|
51
50
|
|
52
51
|
if s.respond_to? :specification_version then
|
53
52
|
s.specification_version = 4
|
53
|
+
end
|
54
54
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
s.add_dependency(%q<glimmer-dsl-swt>.freeze, [">= 4.18.4.3", "< 5.0.0.0"])
|
65
|
-
s.add_dependency(%q<filewatcher>.freeze, ["~> 1.1.1"])
|
66
|
-
s.add_dependency(%q<clipboard>.freeze, ["~> 1.3.5"])
|
67
|
-
s.add_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
|
68
|
-
s.add_dependency(%q<jeweler>.freeze, ["= 2.3.9"])
|
69
|
-
s.add_dependency(%q<warbler>.freeze, ["= 2.0.5"])
|
70
|
-
s.add_dependency(%q<simplecov>.freeze, [">= 0"])
|
71
|
-
end
|
55
|
+
if s.respond_to? :add_runtime_dependency then
|
56
|
+
s.add_runtime_dependency(%q<glimmer-dsl-swt>.freeze, ["~> 4.20.16.0"])
|
57
|
+
s.add_runtime_dependency(%q<filewatcher>.freeze, ["~> 1.1.1"])
|
58
|
+
s.add_runtime_dependency(%q<clipboard>.freeze, ["~> 1.3.5"])
|
59
|
+
s.add_development_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
|
60
|
+
s.add_development_dependency(%q<jeweler>.freeze, ["= 2.3.9"])
|
61
|
+
s.add_development_dependency(%q<warbler>.freeze, ["= 2.0.5"])
|
62
|
+
s.add_development_dependency(%q<jruby-jars>.freeze, ["= 9.2.19.0"])
|
63
|
+
s.add_development_dependency(%q<simplecov>.freeze, [">= 0"])
|
72
64
|
else
|
73
|
-
s.add_dependency(%q<glimmer-dsl-swt>.freeze, ["
|
65
|
+
s.add_dependency(%q<glimmer-dsl-swt>.freeze, ["~> 4.20.16.0"])
|
74
66
|
s.add_dependency(%q<filewatcher>.freeze, ["~> 1.1.1"])
|
75
67
|
s.add_dependency(%q<clipboard>.freeze, ["~> 1.3.5"])
|
76
68
|
s.add_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
|
77
69
|
s.add_dependency(%q<jeweler>.freeze, ["= 2.3.9"])
|
78
70
|
s.add_dependency(%q<warbler>.freeze, ["= 2.0.5"])
|
71
|
+
s.add_dependency(%q<jruby-jars>.freeze, ["= 9.2.19.0"])
|
79
72
|
s.add_dependency(%q<simplecov>.freeze, [">= 0"])
|
80
73
|
end
|
81
74
|
end
|
Binary file
|
@@ -1,6 +1,27 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
1
|
+
# Copyright (c) 2020-2022 Andy Maleh
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
require_relative '../glimmer-cs-gladiator'
|
23
|
+
|
24
|
+
include Glimmer
|
25
|
+
|
26
|
+
local_dir = ENV['LOCAL_DIR'] || '.'
|
27
|
+
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,3 +1,24 @@
|
|
1
|
+
# Copyright (c) 2020-2022 Andy Maleh
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
1
22
|
module Glimmer
|
2
23
|
class Gladiator
|
3
24
|
class Command
|
@@ -1,3 +1,24 @@
|
|
1
|
+
# Copyright (c) 2020-2022 Andy Maleh
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
1
22
|
require 'models/glimmer/gladiator/file'
|
2
23
|
|
3
24
|
module Glimmer
|
@@ -6,7 +27,7 @@ module Glimmer
|
|
6
27
|
include Glimmer
|
7
28
|
include Glimmer::DataBinding::ObservableModel
|
8
29
|
|
9
|
-
IGNORE_PATHS = ['.gladiator', '.git', 'coverage', 'packages', 'node_modules', 'tmp', 'vendor', 'pkg', 'dist']
|
30
|
+
IGNORE_PATHS = ['.gladiator', '.gladiator-scratchpad', '.git', 'coverage', 'packages', 'node_modules', 'tmp', 'vendor', 'pkg', 'dist', 'log']
|
10
31
|
|
11
32
|
attr_accessor :selected_child, :filter, :children, :filtered_path_options, :filtered_path, :display_path, :ignore_paths
|
12
33
|
attr_reader :name, :parent, :path
|
@@ -16,13 +37,13 @@ module Glimmer
|
|
16
37
|
@project_dir = project_dir
|
17
38
|
if is_local_dir
|
18
39
|
@filewatcher = Filewatcher.new(path)
|
19
|
-
Thread.new(@filewatcher) do |fw|
|
40
|
+
@filewatcher_thread = Thread.new(@filewatcher) do |fw|
|
20
41
|
begin
|
21
42
|
fw.watch do |filename, event|
|
22
43
|
# TODO do fine grained processing of events for enhanced performance (e.g. dir refresh vs file change)
|
23
44
|
# TODO do fine grained file change only without a refresh delay for enhanced performance
|
24
45
|
begin
|
25
|
-
if !@refresh_in_progress && !filename.include?('new_file') && (event != :updated || find_child_file(filename).nil?)
|
46
|
+
if !@refresh_in_progress && !filename.include?('new_file') && !ignore_paths.any? { |ignore_path| filename.include?(ignore_path) } && (event != :updated || find_child_file(filename).nil?)
|
26
47
|
Thread.new {
|
27
48
|
refresh
|
28
49
|
}
|
@@ -109,6 +130,19 @@ module Glimmer
|
|
109
130
|
def selected_child_path_history
|
110
131
|
@selected_child_path_history ||= []
|
111
132
|
end
|
133
|
+
|
134
|
+
def close
|
135
|
+
all_children_files.each(&:close)
|
136
|
+
stop_filewatcher
|
137
|
+
end
|
138
|
+
|
139
|
+
def stop_filewatcher
|
140
|
+
@filewatcher&.stop
|
141
|
+
@filewatcher_thread&.kill
|
142
|
+
@filewatcher_thread = nil
|
143
|
+
@filewatcher&.finalize
|
144
|
+
@filewatcher = nil
|
145
|
+
end
|
112
146
|
|
113
147
|
def pause_refresh
|
114
148
|
@refresh_paused = true
|
@@ -177,7 +211,8 @@ module Glimmer
|
|
177
211
|
# scratchpad scenario
|
178
212
|
if selected_path.empty? # Scratchpad
|
179
213
|
@selected_child&.write_dirty_content
|
180
|
-
|
214
|
+
@scratchpad = (self.selected_child = File.new('', project_dir)) if @scratchpad.nil? || @scratchpad.closed?
|
215
|
+
return @scratchpad
|
181
216
|
end
|
182
217
|
full_selected_path = selected_path.include?(project_dir.path) ? selected_path : ::File.join(project_dir.path, selected_path)
|
183
218
|
return if ::Dir.exist?(full_selected_path) ||
|
@@ -188,7 +223,6 @@ module Glimmer
|
|
188
223
|
new_child = find_child_file(selected_path)
|
189
224
|
begin
|
190
225
|
unless new_child.dirty_content.nil?
|
191
|
-
self.selected_child&.stop_filewatcher
|
192
226
|
selected_child_path_history << new_child.path if new_child && !selected_child_path_history.include?(new_child.path)
|
193
227
|
self.selected_child = new_child
|
194
228
|
self.selected_child.start_filewatcher
|
@@ -212,7 +246,7 @@ module Glimmer
|
|
212
246
|
@selected_child.restore_properties(file_properties) if file_properties
|
213
247
|
end
|
214
248
|
|
215
|
-
def
|
249
|
+
def remove!
|
216
250
|
FileUtils.rm_rf(path)
|
217
251
|
end
|
218
252
|
|
@@ -1,3 +1,24 @@
|
|
1
|
+
# Copyright (c) 2020-2022 Andy Maleh
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
1
22
|
module Glimmer
|
2
23
|
class Gladiator
|
3
24
|
class File
|
@@ -28,58 +49,81 @@ module Glimmer
|
|
28
49
|
return 'ruby' if dirty_content.start_with?('#!/usr/bin/env ruby') || dirty_content.start_with?('#!/usr/bin/env jruby')
|
29
50
|
return 'yaml' if path.to_s.end_with?('Gemfile.lock')
|
30
51
|
return 'shell' if extension.nil? && path.to_s.include?('/bin/')
|
52
|
+
return 'make' if path.to_s.end_with?('Makefile') || path.to_s.end_with?('makefile') || path.to_s.end_with?('GNUmakefile')
|
31
53
|
case extension
|
32
54
|
# TODO extract case statement to an external config file
|
33
|
-
when '
|
34
|
-
'ruby'
|
35
|
-
when 'md', 'markdown'
|
36
|
-
'markdown'
|
37
|
-
when 'js', 'es6'
|
38
|
-
'javascript'
|
39
|
-
when 'json'
|
40
|
-
'json'
|
41
|
-
when 'yaml'
|
42
|
-
'yaml'
|
43
|
-
when 'html'
|
44
|
-
'html'
|
45
|
-
when 'h', 'c'
|
55
|
+
when 'c', 'h'
|
46
56
|
'c'
|
47
|
-
when '
|
48
|
-
'
|
49
|
-
when '
|
50
|
-
'gradle'
|
51
|
-
when 'cpp'
|
57
|
+
when 'cr'
|
58
|
+
'crystal'
|
59
|
+
when 'cpp', 'cc', 'C', 'cxx', 'c++', 'hpp', 'hh', 'H', 'hxx', 'h++'
|
52
60
|
'cpp'
|
53
61
|
when 'css'
|
54
62
|
'css'
|
55
|
-
when '
|
56
|
-
'
|
57
|
-
when '
|
58
|
-
'
|
59
|
-
when '
|
60
|
-
'
|
63
|
+
when 'conf'
|
64
|
+
'conf'
|
65
|
+
when 'coffee'
|
66
|
+
'coffeescript'
|
67
|
+
when 'erb'
|
68
|
+
'erb'
|
69
|
+
when 'feature'
|
70
|
+
'gherkin'
|
71
|
+
when 'gradle'
|
72
|
+
'gradle'
|
61
73
|
when 'haml'
|
62
74
|
'haml'
|
63
|
-
when '
|
64
|
-
'
|
75
|
+
when 'html'
|
76
|
+
'html'
|
65
77
|
when 'ini'
|
66
78
|
'ini'
|
79
|
+
when 'java'
|
80
|
+
'java'
|
81
|
+
when 'js', 'cjs', 'mjs', 'es6', 'es'
|
82
|
+
'javascript'
|
83
|
+
when 'json'
|
84
|
+
'json'
|
85
|
+
when 'jsp'
|
86
|
+
'jsp'
|
87
|
+
when 'kt', 'ktm', 'kts'
|
88
|
+
'kotlin'
|
89
|
+
when 'md', 'markdown'
|
90
|
+
'markdown'
|
91
|
+
when 'patch'
|
92
|
+
'diff'
|
67
93
|
when 'pl'
|
68
94
|
'perl'
|
69
|
-
when '
|
70
|
-
'
|
95
|
+
when 'plist'
|
96
|
+
'plist'
|
97
|
+
when 'pp'
|
98
|
+
'puppet'
|
99
|
+
when 'properties'
|
100
|
+
'properties'
|
101
|
+
when 'ps'
|
102
|
+
'postscript'
|
103
|
+
when 'ps1'
|
104
|
+
'powershell'
|
105
|
+
when 'py'
|
106
|
+
'python'
|
107
|
+
when 'rb'
|
108
|
+
'ruby'
|
71
109
|
when 'sass'
|
72
110
|
'sass'
|
111
|
+
when 'scm', 'sps', 'sls', 'sld'
|
112
|
+
'scheme'
|
73
113
|
when 'scss'
|
74
114
|
'scss'
|
75
|
-
when 'sql'
|
76
|
-
'sql'
|
77
115
|
when 'sh'
|
78
116
|
'shell'
|
79
|
-
when '
|
80
|
-
'
|
117
|
+
when 'sql'
|
118
|
+
'sql'
|
119
|
+
when 'tcl'
|
120
|
+
'tcl'
|
81
121
|
when 'txt', nil
|
82
122
|
'plain_text'
|
123
|
+
when 'yaml', 'yml'
|
124
|
+
'yaml'
|
125
|
+
when 'xml'
|
126
|
+
'xml'
|
83
127
|
end
|
84
128
|
end
|
85
129
|
|
@@ -121,8 +165,8 @@ module Glimmer
|
|
121
165
|
unless (current_line_number && current_line_number == new_line_number)
|
122
166
|
self.line_number = new_line_number
|
123
167
|
# TODO check if the following line is needed
|
124
|
-
self.line_position = caret_position - caret_position_for_line_index(line_number - 1) + 1
|
125
168
|
end
|
169
|
+
self.line_position = caret_position - caret_position_for_line_index(line_number - 1) + 1
|
126
170
|
end
|
127
171
|
|
128
172
|
def path=(the_path)
|
@@ -145,7 +189,13 @@ module Glimmer
|
|
145
189
|
end
|
146
190
|
|
147
191
|
def scratchpad?
|
148
|
-
path.to_s.empty?
|
192
|
+
path.to_s.empty? # TODO consider updating to set the .gladiator-scratchpad path directly
|
193
|
+
end
|
194
|
+
|
195
|
+
def scratchpad_file
|
196
|
+
scratchpad_file = ::File.join(project_dir.path, '.gladiator-scratchpad')
|
197
|
+
::File.write(scratchpad_file, content)
|
198
|
+
scratchpad_file
|
149
199
|
end
|
150
200
|
|
151
201
|
def backup_properties
|
@@ -221,20 +271,25 @@ module Glimmer
|
|
221
271
|
end
|
222
272
|
|
223
273
|
def close
|
274
|
+
@closed = true
|
224
275
|
stop_filewatcher
|
225
276
|
remove_all_observers
|
226
277
|
initialize(path, project_dir)
|
227
278
|
Command.clear(self)
|
228
279
|
end
|
229
280
|
|
281
|
+
def closed?
|
282
|
+
@closed
|
283
|
+
end
|
284
|
+
|
230
285
|
def read_dirty_content
|
231
286
|
path.empty? ? '' : ::File.read(path)
|
232
287
|
end
|
233
288
|
|
234
289
|
def start_filewatcher
|
235
290
|
return if scratchpad?
|
236
|
-
@filewatcher
|
237
|
-
@
|
291
|
+
@filewatcher ||= Filewatcher.new(@path)
|
292
|
+
@filewatcher_thread ||= Thread.new(@filewatcher) do |fw|
|
238
293
|
fw.watch do |filename, event|
|
239
294
|
async_exec do
|
240
295
|
begin
|
@@ -250,6 +305,10 @@ module Glimmer
|
|
250
305
|
|
251
306
|
def stop_filewatcher
|
252
307
|
@filewatcher&.stop
|
308
|
+
@filewatcher_thread&.kill
|
309
|
+
@filewatcher_thread = nil
|
310
|
+
@filewatcher&.finalize
|
311
|
+
@filewatcher = nil
|
253
312
|
end
|
254
313
|
|
255
314
|
def write_dirty_content
|
@@ -291,8 +350,8 @@ module Glimmer
|
|
291
350
|
lines[line_number - 1]
|
292
351
|
end
|
293
352
|
|
294
|
-
def
|
295
|
-
FileUtils.
|
353
|
+
def remove!
|
354
|
+
FileUtils.rm_rf(path) unless scratchpad?
|
296
355
|
end
|
297
356
|
|
298
357
|
def prefix_new_line!
|
@@ -508,16 +567,17 @@ module Glimmer
|
|
508
567
|
self.dirty_content = new_dirty_content
|
509
568
|
find_next
|
510
569
|
find_next if replace_text.to_s.include?(find_text) && !replace_text.to_s.start_with?(find_text)
|
570
|
+
write_dirty_content
|
511
571
|
end
|
512
572
|
|
513
573
|
def page_up
|
514
|
-
self.selection_count = 0
|
515
574
|
self.line_number = [(self.line_number - 15), 1].max
|
575
|
+
self.selection_count = 0
|
516
576
|
end
|
517
577
|
|
518
578
|
def page_down
|
519
|
-
self.selection_count = 0
|
520
579
|
self.line_number = [(self.line_number + 15), lines.size].min
|
580
|
+
self.selection_count = 0
|
521
581
|
end
|
522
582
|
|
523
583
|
def home
|
@@ -551,6 +611,7 @@ module Glimmer
|
|
551
611
|
self.selection_count = (caret_position_for_line_index(self.line_number) - 1) - caret_position
|
552
612
|
end
|
553
613
|
|
614
|
+
# deletes content that is highlighted
|
554
615
|
def delete!
|
555
616
|
new_dirty_content = dirty_content
|
556
617
|
new_dirty_content[caret_position...(caret_position + selection_count)] = ''
|
@@ -627,13 +688,13 @@ module Glimmer
|
|
627
688
|
|
628
689
|
def run
|
629
690
|
if scratchpad?
|
630
|
-
|
691
|
+
load scratchpad_file
|
631
692
|
else
|
632
693
|
write_dirty_content
|
633
694
|
load path
|
634
695
|
end
|
635
696
|
end
|
636
|
-
|
697
|
+
|
637
698
|
def lines
|
638
699
|
need_padding = dirty_content.to_s.end_with?("\n")
|
639
700
|
splittable_content = need_padding ? "#{dirty_content} " : dirty_content
|
@@ -1,3 +1,24 @@
|
|
1
|
+
# Copyright (c) 2020-2022 Andy Maleh
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
1
22
|
module Glimmer
|
2
23
|
class Gladiator
|
3
24
|
class FileEditMenu
|