glimmer-cs-gladiator 0.5.1 → 0.5.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5b1fe5cc493fe6df44d316fe7e4fc9e19eb6e0f463724e5bbf1254fb35379463
4
- data.tar.gz: eb399a865ec9e5ab6f4f269cf8c318f8931eda1e014ea557516cc30a979bb249
3
+ metadata.gz: 5de57f9122b239134e9567e99976ed7c5e859edf89a91f72f15f257597ee0815
4
+ data.tar.gz: 99414159618bea5a0a99fd37772424b452f26471ca6e5dd791ff0ce26135646c
5
5
  SHA512:
6
- metadata.gz: 2c20d228ba4421dc54f55206a9c75418c0fe6f1369f27984864c3b22620b42880670d9da3416d5db65e0d3a8028521bddd4f07747fd6cf9fb3a61aec23f617e1
7
- data.tar.gz: 30bec26afe87951052c68b1bf2d6a1e4475d715d9de37664bdb3ecc36584ae363bb941152da4f268db8a119360c165e202ba36b998c6c6feb3df9bbf487ddcac
6
+ metadata.gz: 6e7d7c9cca67e351dbf169d785c6ef927bcd911f03a5b4505fdd2973c9b9291b1a72f8475dceeae592bb3d56de85a65f96b9f1cb96575dc91768d13b46f52749
7
+ data.tar.gz: 35c3dc09a4f5d0e29d8e52dd0cbae1ffc879f6d7cd3d5ec0cc2cbabde3475f3898a959c34d7adf60789c9a8c8fa6e2e5ebcfefe9e5e1db8ba0e7281b268ef572
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # <img src='https://raw.githubusercontent.com/AndyObtiva/glimmer-cs-gladiator/master/images/glimmer-cs-gladiator-logo.svg' height=85 /> Gladiator 0.5.1 - [Ugliest Text Editor Ever](https://www.reddit.com/r/ruby/comments/hgve8k/gladiator_glimmer_editor_ugliest_text_editor_ever/)
1
+ # <img src='https://raw.githubusercontent.com/AndyObtiva/glimmer-cs-gladiator/master/images/glimmer-cs-gladiator-logo.svg' height=85 /> Gladiator 0.5.2 - [Ugliest Text Editor Ever](https://www.reddit.com/r/ruby/comments/hgve8k/gladiator_glimmer_editor_ugliest_text_editor_ever/)
2
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
 
@@ -103,7 +103,7 @@ To reuse Gladiator as a Glimmer Custom Shell inside another Glimmer application,
103
103
  following to the application's `Gemfile`:
104
104
 
105
105
  ```
106
- gem 'glimmer-cs-gladiator', '~> 0.5.1'
106
+ gem 'glimmer-cs-gladiator', '~> 0.5.2'
107
107
  ```
108
108
 
109
109
  Run:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.1
1
+ 0.5.2
@@ -23,7 +23,7 @@ module Glimmer
23
23
  args = SWTProxy.constantify_args(args)
24
24
  @swt_layout = self.class.swt_layout_class_for(underscored_layout_name).new(*args)
25
25
  @widget_proxy.swt_widget.setLayout(@swt_layout)
26
- end
26
+ end
27
27
  end
28
28
  end
29
29
  end
@@ -1,6 +1,6 @@
1
1
  module Glimmer
2
2
  class Gladiator
3
- class Command
3
+ class Command
4
4
  class << self
5
5
  include Glimmer
6
6
 
@@ -10,10 +10,10 @@ module Glimmer
10
10
 
11
11
  def command_history_for(file)
12
12
  # keeping a first command to make redo support work by remembering next command after undoing all
13
- command_history[file] ||= [Command.new(file)]
13
+ command_history[file] ||= [Command.new(file)]
14
14
  end
15
15
 
16
- def do(file, method = nil, command: nil)
16
+ def do(file, method = nil, command: nil)
17
17
  command ||= Command.new(file, method)
18
18
  command_history_for(file)&.last&.next_command = command
19
19
  command.do
@@ -21,7 +21,7 @@ module Glimmer
21
21
  end
22
22
 
23
23
  def undo(file)
24
- return if command_history_for(file).size <= 1
24
+ return if command_history_for(file).size <= 1
25
25
  command = command_history_for(file).pop
26
26
  command&.undo
27
27
  end
@@ -48,6 +48,14 @@ module Glimmer
48
48
  is_local_dir ? path : @display_path = @path.sub(project_dir.path, '').sub(/^\//, '')
49
49
  end
50
50
 
51
+ def name=(the_name)
52
+ self.display_path = display_path.sub(/#{Regexp.escape(@name)}$/, the_name)
53
+ @name = the_name
54
+ new_path = ::File.expand_path(display_path)
55
+ FileUtils.mv(path, new_path)
56
+ self.path = display_path
57
+ end
58
+
51
59
  def children
52
60
  @children ||= retrieve_children
53
61
  end
@@ -51,7 +51,7 @@ module Glimmer
51
51
  end
52
52
 
53
53
  def scratchpad?
54
- path.empty?
54
+ path.to_s.empty?
55
55
  end
56
56
 
57
57
  def backup_properties
@@ -98,6 +98,15 @@ module Glimmer
98
98
  self.selection = Point.new(caret_position, caret_position + value.to_i)
99
99
  end
100
100
 
101
+ def name=(the_name)
102
+ new_path = path.sub(/#{Regexp.escape(@name)}$/, the_name) unless scratchpad?
103
+ @name = the_name
104
+ if !scratchpad? && ::File.exist?(path)
105
+ FileUtils.mv(path, new_path)
106
+ self.path = new_path
107
+ end
108
+ end
109
+
101
110
  def dirty_content=(the_content)
102
111
  @dirty_content = the_content
103
112
  notify_observers(:content)
@@ -23,7 +23,7 @@ module Glimmer
23
23
  attr_accessor :drag_and_drop
24
24
  attr_accessor :drag
25
25
  end
26
-
26
+
27
27
  ## Add options like the following to configure CustomShell by outside consumers
28
28
  #
29
29
  # options :title, :background_color
@@ -42,9 +42,8 @@ module Glimmer
42
42
  #
43
43
  #
44
44
  before_body {
45
- Thread.new {
46
- project_dir #pre-initialize directory
47
- }
45
+ # TODO consider doing loading project files after displaying the GUI instead of holding it up before
46
+ project_dir #pre-initialize directory
48
47
  at_exit do
49
48
  project_dir.selected_child&.write_raw_dirty_content
50
49
  end
@@ -582,8 +581,12 @@ module Glimmer
582
581
  end
583
582
  end
584
583
 
584
+ def find_tab_item(file_path)
585
+ @current_tab_folder.swt_widget.getItems.detect { |ti| ti.getData('file_path') == file_path }
586
+ end
587
+
585
588
  def selected_tab_item
586
- @current_tab_folder.swt_widget.getItems.detect { |ti| ti.getData('file_path') == project_dir.selected_child&.path }
589
+ find_tab_item(project_dir.selected_child&.path)
587
590
  end
588
591
 
589
592
  def other_tab_items
@@ -615,19 +618,15 @@ module Glimmer
615
618
  @file_tree.swt_widget.showItem(parent_tree_item)
616
619
  parent_tree_item.setExpanded(true)
617
620
  # TODO close text editor tab
618
- # if file.is_a?(::File)
619
- # close tab
620
- # end
621
+ found_tab_item = find_tab_item(file.path)
622
+ if found_tab_item
623
+ project_dir.selected_child_path_history.delete(found_tab_item.getData('file_path'))
624
+ found_tab_item.getData('proxy')&.dispose
625
+ end
621
626
  rescue => e
622
627
  puts e.full_message
623
628
  end
624
629
 
625
- def rename_selected_tree_item
626
- project_dir.pause_refresh
627
- tree_item = @file_tree.swt_widget.getSelection.first
628
- rename_tree_item(tree_item)
629
- end
630
-
631
630
  def add_new_directory_to_selected_tree_item
632
631
  project_dir.pause_refresh
633
632
  tree_item = @file_tree.swt_widget.getSelection.first
@@ -642,7 +641,7 @@ module Glimmer
642
641
  project_dir.refresh(async: false, force: true)
643
642
  new_tree_item = @file_tree.depth_first_search {|ti| ti.getData.path == new_directory_path}.first
644
643
  @file_tree.swt_widget.showItem(new_tree_item)
645
- rename_tree_item(new_tree_item, true)
644
+ rename_tree_item(new_tree_item)
646
645
  end
647
646
 
648
647
  def add_new_file_to_selected_tree_item
@@ -662,14 +661,37 @@ module Glimmer
662
661
  rename_tree_item(new_tree_item, true)
663
662
  end
664
663
 
665
- def rename_tree_item(tree_item, open_afterwards = false)
664
+ def rename_selected_tree_item
665
+ project_dir.pause_refresh
666
+ tree_item = @file_tree.swt_widget.getSelection.first
667
+ rename_tree_item(tree_item)
668
+ end
669
+
670
+ def rename_tree_item(tree_item, new_file = false)
671
+ original_file = tree_item.getData
672
+ current_file = project_dir.selected_child_path == original_file.path
673
+ found_tab_item = find_tab_item(original_file.path)
674
+ found_text_editor = found_tab_item&.getData('text_editor')
666
675
  @file_tree.edit_tree_item(
667
676
  tree_item,
668
677
  after_write: -> (edited_tree_item) {
669
678
  file = edited_tree_item.getData
670
679
  file_path = file.path
671
- # TODO rename file in tab title
672
- project_dir.selected_child_path = file_path if open_afterwards
680
+ file.name
681
+ if new_file
682
+ project_dir.selected_child_path = file_path
683
+ else
684
+ found_text_editor&.file = file
685
+ found_tab_item&.setData('file', file)
686
+ found_tab_item&.setData('file_path', file.path)
687
+ found_tab_item&.setText(file.name)
688
+ body_root.pack_same_size
689
+ if current_file
690
+ project_dir.selected_child_path = file_path
691
+ else
692
+ selected_tab_item&.getData('text_editor')&.text_widget&.setFocus
693
+ end
694
+ end
673
695
  project_dir.resume_refresh
674
696
  },
675
697
  after_cancel: -> {
@@ -26,12 +26,13 @@ module Glimmer
26
26
  font name: 'Consolas', height: OS.mac? ? 15 : 12
27
27
  background color(:widget_background)
28
28
  foreground rgb(0, 0, 250)
29
- text bind(file, 'line_numbers_content')
30
- top_pixel bind(file, 'top_pixel', read_only: true)
29
+ text bind(self, 'file.line_numbers_content')
30
+ top_pixel bind(self, 'file.top_pixel', read_only: true)
31
31
  top_margin 5
32
32
  right_margin 5
33
33
  bottom_margin 5
34
34
  left_margin 5
35
+ editable false
35
36
  on_focus_gained {
36
37
  @text&.swt_widget.setFocus
37
38
  }
@@ -47,10 +48,10 @@ module Glimmer
47
48
  layout_data :fill, :fill, true, true
48
49
  font name: 'Consolas', height: OS.mac? ? 15 : 12
49
50
  foreground rgb(75, 75, 75)
50
- text bind(file, :content)
51
+ text bind(self, 'file.content')
51
52
  focus true
52
- selection bind(file, :selection)
53
- top_pixel bind(file, 'top_pixel')
53
+ selection bind(self, 'file.selection')
54
+ top_pixel bind(self, 'file.top_pixel')
54
55
  drop_target(DND::DROP_COPY) {
55
56
  transfer [TextTransfer.getInstance].to_java(Transfer)
56
57
  on_drag_enter { |event|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-cs-gladiator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
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-01 00:00:00.000000000 Z
11
+ date: 2020-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement