glimmer-cs-gladiator 0.3.1 → 0.4.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 +8 -3
- data/VERSION +1 -1
- data/lib/models/glimmer/gladiator/command.rb +8 -4
- data/lib/models/glimmer/gladiator/file.rb +28 -17
- data/lib/views/glimmer/gladiator.rb +59 -8
- data/lib/views/glimmer/gladiator/text_editor.rb +21 -12
- metadata +4 -4
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 1b17d21c81f04c1f1fc1ad516013d9e62a6abeb0900096b1bd13c95c6cf10ccd
         | 
| 4 | 
            +
              data.tar.gz: 78d41ab949f3f40c71f2abfa26310a32f3720eecb64dcf5b90d2f155c2b35345
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: bff6362c1eb4cc711c507ac90aa34e5a5b11653fe7b48f475bd829b37fdb1a87ca6b2317b35ff11f14f287aebfe2e35dee5e47ea2e9575f74c7b9971a1231b77
         | 
| 7 | 
            +
              data.tar.gz: dc19f782cfb448e32f8054fee66797001af383cdcbedf26aeed3a3beaddef4309edefa4ca59c9be4192cd534d8a670bed35bd691ee458e3c5d22a43938e9d5e2
         | 
    
        data/README.md
    CHANGED
    
    | @@ -1,10 +1,12 @@ | |
| 1 | 
            -
            # <img src='https://raw.githubusercontent.com/AndyObtiva/glimmer-cs-gladiator/master/images/glimmer-cs-gladiator-logo.svg' height=85 /> Gladiator 0. | 
| 1 | 
            +
            # <img src='https://raw.githubusercontent.com/AndyObtiva/glimmer-cs-gladiator/master/images/glimmer-cs-gladiator-logo.svg' height=85 /> Gladiator 0.4.0 - [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 | 
             
            [](http://badge.fury.io/rb/glimmer-cs-gladiator)
         | 
| 4 4 |  | 
| 5 5 | 
             
            
         | 
| 6 6 |  | 
| 7 | 
            -
             | 
| 7 | 
            +
            (Now, slightly less ugly with Ruby syntax highlighting colors)
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            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 Ruby using [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) (JRuby Desktop Development GUI Library).
         | 
| 8 10 | 
             
            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 11 | 
             
            Gladiator is also a personal tool for shaping an editor exactly the way I like, with all the keyboard shortcuts I prefer. 
         | 
| 10 12 | 
             
            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.
         | 
| @@ -12,6 +14,7 @@ I leave building truly professional text editors to software tooling experts who | |
| 12 14 | 
             
            ## Features
         | 
| 13 15 |  | 
| 14 16 | 
             
            Gladiator currently supports the following text editing features (including keyboard shortcuts with Mac CMD=CTRL on Windows/Linux):
         | 
| 17 | 
            +
            - Ruby Syntax Highlighting with colors
         | 
| 15 18 | 
             
            - File explorer navigation with context menu to open file, rename, delete, add new file, add new directory, or refresh tree (CMD+T)
         | 
| 16 19 | 
             
            - File lookup by name ignoring slashes, underscores, and dots to ease lookup (CMD+R)
         | 
| 17 20 | 
             
            - Watch open file for external changes to automatically refresh in editor
         | 
| @@ -30,6 +33,8 @@ Gladiator currently supports the following text editing features (including keyb | |
| 30 33 | 
             
            - Indent/Unindent line/selection (CMD+] & CMD+[)
         | 
| 31 34 | 
             
            - Insert/Prefix New Line (CMD+ENTER & CMD+SHIFT+ENTER)
         | 
| 32 35 | 
             
            - Drag and Drop Text Editor Split Screen (drag a file from File Tree or File Lookup List, and it splits the screen)
         | 
| 36 | 
            +
            - Run current Ruby file via Run Menu (CMD+SHIFT+R)
         | 
| 37 | 
            +
            - Change Split Orientation to Horizontal/Vertical via View Menu (CMD+SHIFT+O)
         | 
| 33 38 |  | 
| 34 39 | 
             
            ## Platforms
         | 
| 35 40 |  | 
| @@ -99,7 +104,7 @@ To reuse Gladiator as a Glimmer Custom Shell inside another Glimmer application, | |
| 99 104 | 
             
            following to the application's `Gemfile`:
         | 
| 100 105 |  | 
| 101 106 | 
             
            ```
         | 
| 102 | 
            -
            gem 'glimmer-cs-gladiator', '~> 0. | 
| 107 | 
            +
            gem 'glimmer-cs-gladiator', '~> 0.4.0'
         | 
| 103 108 | 
             
            ```
         | 
| 104 109 |  | 
| 105 110 | 
             
            Run:
         | 
    
        data/VERSION
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            0. | 
| 1 | 
            +
            0.4.0
         | 
| @@ -1,7 +1,9 @@ | |
| 1 1 | 
             
            module Glimmer
         | 
| 2 2 | 
             
              class Gladiator
         | 
| 3 | 
            -
                class Command
         | 
| 3 | 
            +
                class Command    
         | 
| 4 4 | 
             
                  class << self
         | 
| 5 | 
            +
                    include Glimmer
         | 
| 6 | 
            +
                    
         | 
| 5 7 | 
             
                    def command_history
         | 
| 6 8 | 
             
                      @command_history ||= {}
         | 
| 7 9 | 
             
                    end
         | 
| @@ -11,7 +13,7 @@ module Glimmer | |
| 11 13 | 
             
                      command_history[file] ||= [Command.new(file)] 
         | 
| 12 14 | 
             
                    end
         | 
| 13 15 |  | 
| 14 | 
            -
                    def do(file, method = nil, command: nil)
         | 
| 16 | 
            +
                    def do(file, method = nil, command: nil)        
         | 
| 15 17 | 
             
                      command ||= Command.new(file, method)
         | 
| 16 18 | 
             
                      command_history_for(file)&.last&.next_command = command
         | 
| 17 19 | 
             
                      command.do
         | 
| @@ -20,11 +22,13 @@ module Glimmer | |
| 20 22 |  | 
| 21 23 | 
             
                    def undo(file)
         | 
| 22 24 | 
             
                      return if command_history_for(file).size <= 1        
         | 
| 23 | 
            -
                      command_history_for(file).pop | 
| 25 | 
            +
                      command = command_history_for(file).pop
         | 
| 26 | 
            +
                      command&.undo
         | 
| 24 27 | 
             
                    end
         | 
| 25 28 |  | 
| 26 29 | 
             
                    def redo(file)
         | 
| 27 | 
            -
                      command_history_for(file).last | 
| 30 | 
            +
                      command = command_history_for(file).last
         | 
| 31 | 
            +
                      command&.redo
         | 
| 28 32 | 
             
                    end
         | 
| 29 33 | 
             
                  end
         | 
| 30 34 |  | 
| @@ -5,15 +5,15 @@ module Glimmer | |
| 5 5 | 
             
                class File
         | 
| 6 6 | 
             
                  include Glimmer
         | 
| 7 7 |  | 
| 8 | 
            -
                  attr_accessor :dirty_content, :line_numbers_content, :selection, : | 
| 8 | 
            +
                  attr_accessor :dirty_content, :line_numbers_content, :selection, :line_number, :find_text, :replace_text, :top_pixel, :display_path, :case_sensitive
         | 
| 9 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 14 | 
             
                    @name = ::File.basename(path)
         | 
| 15 15 | 
             
                    self.path = ::File.expand_path(path)
         | 
| 16 | 
            -
                    @ | 
| 16 | 
            +
                    @top_pixel = 0
         | 
| 17 17 | 
             
                    @selection_count = 0
         | 
| 18 18 | 
             
                    @selection = Point.new(0, 0 + @selection_count)
         | 
| 19 19 | 
             
                    read_dirty_content = ::File.read(path)
         | 
| @@ -52,8 +52,11 @@ module Glimmer | |
| 52 52 |  | 
| 53 53 | 
             
                  # to use for widget data-binding
         | 
| 54 54 | 
             
                  def content=(value)
         | 
| 55 | 
            -
                     | 
| 56 | 
            -
                     | 
| 55 | 
            +
                    value = value.gsub("\t", '  ')
         | 
| 56 | 
            +
                    if dirty_content != value
         | 
| 57 | 
            +
                      Command.do(self) # record a native (OS-widget) operation
         | 
| 58 | 
            +
                      self.dirty_content = value
         | 
| 59 | 
            +
                    end
         | 
| 57 60 | 
             
                  end
         | 
| 58 61 |  | 
| 59 62 | 
             
                  def content
         | 
| @@ -61,18 +64,23 @@ module Glimmer | |
| 61 64 | 
             
                  end
         | 
| 62 65 |  | 
| 63 66 | 
             
                  def caret_position=(value)
         | 
| 67 | 
            +
                    old_top_pixel = top_pixel
         | 
| 64 68 | 
             
                    self.selection = Point.new(value, value + selection_count.to_i)
         | 
| 65 | 
            -
                     | 
| 66 | 
            -
                      async_exec do
         | 
| 67 | 
            -
                        self.top_index = line_index_for_caret_position(value)
         | 
| 68 | 
            -
                      end
         | 
| 69 | 
            -
                    end
         | 
| 69 | 
            +
                    self.top_pixel = old_top_pixel
         | 
| 70 70 | 
             
                  end
         | 
| 71 71 |  | 
| 72 72 | 
             
                  def caret_position
         | 
| 73 73 | 
             
                    selection.x
         | 
| 74 74 | 
             
                  end
         | 
| 75 | 
            +
             | 
| 76 | 
            +
                  def selection_count
         | 
| 77 | 
            +
                    selection.y - selection.x
         | 
| 78 | 
            +
                  end
         | 
| 75 79 |  | 
| 80 | 
            +
                  def selection_count=(value)
         | 
| 81 | 
            +
                    self.selection = Point.new(caret_position, caret_position + value.to_i)
         | 
| 82 | 
            +
                  end      
         | 
| 83 | 
            +
                              
         | 
| 76 84 | 
             
                  def name=(the_name)
         | 
| 77 85 | 
             
                    new_path = path.sub(/#{Regexp.escape(@name)}$/, the_name)
         | 
| 78 86 | 
             
                    @name = the_name
         | 
| @@ -135,10 +143,10 @@ module Glimmer | |
| 135 143 | 
             
                    current_line.to_s.match(/^(\s+)/).to_a[1].to_s
         | 
| 136 144 | 
             
                  end
         | 
| 137 145 |  | 
| 138 | 
            -
                  def current_line
         | 
| 146 | 
            +
                  def current_line      
         | 
| 139 147 | 
             
                    lines[line_number - 1]
         | 
| 140 148 | 
             
                  end
         | 
| 141 | 
            -
             | 
| 149 | 
            +
             | 
| 142 150 | 
             
                  def delete!
         | 
| 143 151 | 
             
                    FileUtils.rm(path)        
         | 
| 144 152 | 
             
                  end
         | 
| @@ -210,8 +218,9 @@ module Glimmer | |
| 210 218 | 
             
                    old_caret_position = self.caret_position
         | 
| 211 219 | 
             
                    self.dirty_content = new_lines.join("\n")   
         | 
| 212 220 | 
             
                    if old_selection_count.to_i > 0
         | 
| 213 | 
            -
                       | 
| 214 | 
            -
                       | 
| 221 | 
            +
                      caret_position_value = caret_position_for_line_index(old_caret_position_line_index)
         | 
| 222 | 
            +
                      selection_count_value = (caret_position_for_line_index(old_end_caret_line_index + 1) - caret_position_value)
         | 
| 223 | 
            +
                      self.selection = Point.new(caret_position_value, caret_position_value + selection_count_value)
         | 
| 215 224 | 
             
                    else
         | 
| 216 225 | 
             
                      self.caret_position = old_caret_position + delta
         | 
| 217 226 | 
             
                    end
         | 
| @@ -239,8 +248,9 @@ module Glimmer | |
| 239 248 | 
             
                    end
         | 
| 240 249 | 
             
                    self.dirty_content = new_lines.join("\n")   
         | 
| 241 250 | 
             
                    if old_selection_count.to_i > 0
         | 
| 242 | 
            -
                       | 
| 243 | 
            -
                       | 
| 251 | 
            +
                      caret_position_value = caret_position_for_line_index(old_caret_position_line_index)
         | 
| 252 | 
            +
                      selection_count_value = (caret_position_for_line_index(old_end_caret_line_index + 1) - caret_position_value)
         | 
| 253 | 
            +
                      self.selection = Point.new(caret_position_value, caret_position_value + selection_count_value)
         | 
| 244 254 | 
             
                    else
         | 
| 245 255 | 
             
                      new_caret_position = old_caret_position + delta
         | 
| 246 256 | 
             
                      new_caret_position = [new_caret_position, old_caret_position_line_caret_position].max
         | 
| @@ -290,7 +300,7 @@ module Glimmer | |
| 290 300 | 
             
                    all_lines = lines
         | 
| 291 301 | 
             
                    the_line_index = line_index_for_caret_position(caret_position)
         | 
| 292 302 | 
             
                    line_position = line_position_for_caret_position(caret_position)
         | 
| 293 | 
            -
                    found = 
         | 
| 303 | 
            +
                    found = found_text?(caret_position)
         | 
| 294 304 | 
             
                    2.times do |i|
         | 
| 295 305 | 
             
                      rotation = the_line_index
         | 
| 296 306 | 
             
                      all_lines.rotate(rotation).each_with_index do |the_line, the_index|
         | 
| @@ -302,6 +312,7 @@ module Glimmer | |
| 302 312 | 
             
                        if occurrence_index
         | 
| 303 313 | 
             
                          self.caret_position = caret_position_for_line_index(the_index) + start_position + occurrence_index
         | 
| 304 314 | 
             
                          self.selection_count = find_text.to_s.size
         | 
| 315 | 
            +
                          self.selection = Point.new(self.caret_position, self.caret_position + self.selection_count)
         | 
| 305 316 | 
             
                          return
         | 
| 306 317 | 
             
                        end
         | 
| 307 318 | 
             
                      end
         | 
| @@ -15,6 +15,7 @@ module Glimmer | |
| 15 15 | 
             
              class Gladiator
         | 
| 16 16 | 
             
                include Glimmer::UI::CustomShell
         | 
| 17 17 |  | 
| 18 | 
            +
                APP_ROOT = ::File.expand_path('../../../..', __FILE__)  
         | 
| 18 19 | 
             
                COMMAND_KEY = OS.mac? ? :command : :ctrl
         | 
| 19 20 |  | 
| 20 21 | 
             
                class << self
         | 
| @@ -28,6 +29,8 @@ module Glimmer | |
| 28 29 | 
             
                # option :width, 320
         | 
| 29 30 | 
             
                # option :height, 240
         | 
| 30 31 |  | 
| 32 | 
            +
                attr_accessor :split_orientation
         | 
| 33 | 
            +
                
         | 
| 31 34 | 
             
                ## Uncomment before_body block to pre-initialize variables to use in body
         | 
| 32 35 | 
             
                #
         | 
| 33 36 | 
             
                #
         | 
| @@ -72,6 +75,8 @@ module Glimmer | |
| 72 75 | 
             
                            @text_editor&.text_widget&.setFocus
         | 
| 73 76 | 
             
                          end
         | 
| 74 77 | 
             
                        end
         | 
| 78 | 
            +
                      elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY, :shift) && extract_char(key_event) == 'o'
         | 
| 79 | 
            +
                        self.split_orientation = split_orientation == swt(:horizontal) ? swt(:vertical) : swt(:horizontal)
         | 
| 75 80 | 
             
                      elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY, :shift) && extract_char(key_event) == ']'
         | 
| 76 81 | 
             
                        @tab_folder.swt_widget.setSelection((@tab_folder.swt_widget.getSelectionIndex() + 1) % @tab_folder.swt_widget.getItemCount) if @tab_folder.swt_widget.getItemCount > 0
         | 
| 77 82 | 
             
                        @text_editor&.text_widget&.setFocus
         | 
| @@ -132,10 +137,10 @@ module Glimmer | |
| 132 137 | 
             
                      elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY) && extract_char(key_event) == 'l'
         | 
| 133 138 | 
             
                        @line_number_text.swt_widget.selectAll
         | 
| 134 139 | 
             
                        @line_number_text.swt_widget.setFocus
         | 
| 135 | 
            -
                      elsif  | 
| 140 | 
            +
                      elsif key_event.stateMask == swt(COMMAND_KEY) && extract_char(key_event) == 'r'
         | 
| 136 141 | 
             
                        @filter_text.swt_widget.selectAll
         | 
| 137 142 | 
             
                        @filter_text.swt_widget.setFocus
         | 
| 138 | 
            -
                      elsif  | 
| 143 | 
            +
                      elsif key_event.stateMask == swt(COMMAND_KEY) && extract_char(key_event) == 't'
         | 
| 139 144 | 
             
                        select_tree_item unless @rename_in_progress
         | 
| 140 145 | 
             
                        @tree.swt_widget.setFocus
         | 
| 141 146 | 
             
                      elsif key_event.keyCode == swt(:esc)
         | 
| @@ -147,6 +152,7 @@ module Glimmer | |
| 147 152 | 
             
                    }
         | 
| 148 153 | 
             
                  }
         | 
| 149 154 |  | 
| 155 | 
            +
                  @split_orientation = swt(:horizontal)
         | 
| 150 156 | 
             
                  local_dir = ENV['LOCAL_DIR'] || '.'
         | 
| 151 157 | 
             
                  @config_file_path = ::File.join(local_dir, '.gladiator')
         | 
| 152 158 | 
             
                  @config = {}
         | 
| @@ -223,7 +229,7 @@ module Glimmer | |
| 223 229 | 
             
                  observe(Dir.local_dir, 'selected_child.caret_position') do
         | 
| 224 230 | 
             
                    save_config
         | 
| 225 231 | 
             
                  end
         | 
| 226 | 
            -
                  observe(Dir.local_dir, 'selected_child. | 
| 232 | 
            +
                  observe(Dir.local_dir, 'selected_child.top_pixel') do
         | 
| 227 233 | 
             
                    save_config
         | 
| 228 234 | 
             
                  end
         | 
| 229 235 | 
             
                  load_config
         | 
| @@ -258,6 +264,46 @@ module Glimmer | |
| 258 264 | 
             
                    on_shell_deactivated {
         | 
| 259 265 | 
             
                      @text_editor&.file&.write_dirty_content
         | 
| 260 266 | 
             
                    }        
         | 
| 267 | 
            +
             | 
| 268 | 
            +
                    menu_bar {
         | 
| 269 | 
            +
                      menu {
         | 
| 270 | 
            +
                        text '&View'
         | 
| 271 | 
            +
                        menu {
         | 
| 272 | 
            +
                          text '&Split'
         | 
| 273 | 
            +
                          menu_item(:radio) {
         | 
| 274 | 
            +
                            text '&Horizontal'
         | 
| 275 | 
            +
                            selection bind(self, :split_orientation, on_read: ->(o) { o == swt(:horizontal)}, on_write: ->(b) { b ? swt(:horizontal) : swt(:vertical)})
         | 
| 276 | 
            +
                          }
         | 
| 277 | 
            +
                          menu_item(:radio) {
         | 
| 278 | 
            +
                            text '&Vertical'
         | 
| 279 | 
            +
                            selection bind(self, :split_orientation, on_read: ->(o) { o == swt(:vertical)}, on_write: ->(b) { b ? swt(:vertical) : swt(:horizontal)})
         | 
| 280 | 
            +
                          }
         | 
| 281 | 
            +
                        }
         | 
| 282 | 
            +
                      }
         | 
| 283 | 
            +
                      menu {
         | 
| 284 | 
            +
                        text '&Run'
         | 
| 285 | 
            +
            #             menu_item {
         | 
| 286 | 
            +
            #               text 'Launch Glimmer &App'
         | 
| 287 | 
            +
            #               on_widget_selected {
         | 
| 288 | 
            +
            #                 parent_path = Dir.local_dir.path
         | 
| 289 | 
            +
            ##                 current_directory_name = ::File.basename(parent_path)
         | 
| 290 | 
            +
            ##                 assumed_shell_script = ::File.join(parent_path, 'bin', current_directory_name)      
         | 
| 291 | 
            +
            ##                 assumed_shell_script = ::Dir.glob(::File.join(parent_path, 'bin', '*')).detect {|f| ::File.file?(f) && !::File.read(f).include?('#!/usr/bin/env')} if !::File.exist?(assumed_shell_script)
         | 
| 292 | 
            +
            ##                 load assumed_shell_script
         | 
| 293 | 
            +
            #                 FileUtils.cd(parent_path) do
         | 
| 294 | 
            +
            #                   system 'glimmer run'
         | 
| 295 | 
            +
            #                 end
         | 
| 296 | 
            +
            #               }
         | 
| 297 | 
            +
            #             }
         | 
| 298 | 
            +
                        menu_item {
         | 
| 299 | 
            +
                          text '&Current File'
         | 
| 300 | 
            +
                          on_widget_selected {
         | 
| 301 | 
            +
                            load Dir.local_dir.selected_child.path
         | 
| 302 | 
            +
                          }
         | 
| 303 | 
            +
                        }
         | 
| 304 | 
            +
                      }
         | 
| 305 | 
            +
                    }
         | 
| 306 | 
            +
             | 
| 261 307 | 
             
                    composite {
         | 
| 262 308 | 
             
                      grid_layout 1, false
         | 
| 263 309 | 
             
                      layout_data(:fill, :fill, false, true) {
         | 
| @@ -395,9 +441,13 @@ module Glimmer | |
| 395 441 |  | 
| 396 442 | 
             
                        # row 1
         | 
| 397 443 |  | 
| 444 | 
            +
                        label {
         | 
| 445 | 
            +
                          text 'File:'
         | 
| 446 | 
            +
                        }
         | 
| 447 | 
            +
             | 
| 398 448 | 
             
                        @file_path_label = styled_text(:none) {
         | 
| 399 449 | 
             
                          layout_data(:fill, :fill, true, false) {
         | 
| 400 | 
            -
                            horizontal_span  | 
| 450 | 
            +
                            horizontal_span 2
         | 
| 401 451 | 
             
                          }
         | 
| 402 452 | 
             
                          background color(:widget_background)
         | 
| 403 453 | 
             
                          editable false
         | 
| @@ -496,6 +546,7 @@ module Glimmer | |
| 496 546 | 
             
                          height_hint 480
         | 
| 497 547 | 
             
                        }
         | 
| 498 548 | 
             
                        sash_width 10
         | 
| 549 | 
            +
                        orientation bind(self, :split_orientation)
         | 
| 499 550 | 
             
                        @tab_folder = tab_folder {
         | 
| 500 551 | 
             
                          drag_source(DND::DROP_COPY) {
         | 
| 501 552 | 
             
                            transfer [TextTransfer.getInstance].to_java(Transfer)
         | 
| @@ -549,7 +600,7 @@ module Glimmer | |
| 549 600 | 
             
                    Gladiator.drag = false
         | 
| 550 601 | 
             
                    Dir.local_dir.selected_child_path = @config[:selected_child_path] if @config[:selected_child_path]
         | 
| 551 602 | 
             
                    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&. | 
| 603 | 
            +
                    Dir.local_dir.selected_child&.top_pixel = @config[:top_pixel].to_i if @config[:top_pixel]
         | 
| 553 604 | 
             
                  else
         | 
| 554 605 | 
             
                    @loaded_config = true
         | 
| 555 606 | 
             
                  end
         | 
| @@ -561,12 +612,12 @@ module Glimmer | |
| 561 612 | 
             
                  return if child.nil?
         | 
| 562 613 | 
             
                  tab_folder1 = @tab_folder1 || @tab_folder
         | 
| 563 614 | 
             
                  tab_folder2 = @tab_folder2
         | 
| 564 | 
            -
                  open_file_paths1 = tab_folder1&.swt_widget&.items | 
| 565 | 
            -
                  open_file_paths2 = tab_folder2&.swt_widget&.items | 
| 615 | 
            +
                  open_file_paths1 = tab_folder1&.swt_widget&.items.to_a.map {|i| i.get_data('file_path')}
         | 
| 616 | 
            +
                  open_file_paths2 = tab_folder2&.swt_widget&.items.to_a.map {|i| i.get_data('file_path')}
         | 
| 566 617 | 
             
                  @config = {
         | 
| 567 618 | 
             
                    selected_child_path: child.path,
         | 
| 568 619 | 
             
                    caret_position: child.caret_position,
         | 
| 569 | 
            -
                     | 
| 620 | 
            +
                    top_pixel: child.top_pixel,
         | 
| 570 621 | 
             
                    shell_width: swt_widget&.getBounds&.width,
         | 
| 571 622 | 
             
                    shell_height: swt_widget&.getBounds&.height,
         | 
| 572 623 | 
             
                    shell_x: swt_widget&.getBounds&.x,
         | 
| @@ -16,13 +16,13 @@ module Glimmer | |
| 16 16 | 
             
                    composite {
         | 
| 17 17 | 
             
                      layout_data :fill, :fill, true, true
         | 
| 18 18 | 
             
                      grid_layout 2, false
         | 
| 19 | 
            -
                      @line_numbers_text =  | 
| 19 | 
            +
                      @line_numbers_text = code_text(:border, :multi) {
         | 
| 20 20 | 
             
                        layout_data(:right, :fill, false, true)
         | 
| 21 21 | 
             
                        font name: 'Consolas', height: OS.mac? ? 15 : 12
         | 
| 22 22 | 
             
                        background color(:widget_background)
         | 
| 23 23 | 
             
                        foreground rgb(75, 75, 75)
         | 
| 24 24 | 
             
                        text bind(file, 'line_numbers_content')
         | 
| 25 | 
            -
                         | 
| 25 | 
            +
                        top_pixel bind(file, 'top_pixel', read_only: true)
         | 
| 26 26 | 
             
                        on_focus_gained {
         | 
| 27 27 | 
             
                          @text&.swt_widget.setFocus
         | 
| 28 28 | 
             
                        }
         | 
| @@ -33,15 +33,15 @@ module Glimmer | |
| 33 33 | 
             
                          @text&.swt_widget.setFocus
         | 
| 34 34 | 
             
                        }
         | 
| 35 35 | 
             
                      }
         | 
| 36 | 
            -
                       | 
| 36 | 
            +
                      
         | 
| 37 | 
            +
                      @text = code_text {
         | 
| 37 38 | 
             
                        layout_data :fill, :fill, true, true
         | 
| 38 39 | 
             
                        font name: 'Consolas', height: OS.mac? ? 15 : 12
         | 
| 39 40 | 
             
                        foreground rgb(75, 75, 75)
         | 
| 40 41 | 
             
                        text bind(file, :content)
         | 
| 41 42 | 
             
                        focus true
         | 
| 42 | 
            -
                        selection bind(file,  | 
| 43 | 
            -
                         | 
| 44 | 
            -
                        top_index bind(file, 'top_index')
         | 
| 43 | 
            +
                        selection bind(file, :selection)
         | 
| 44 | 
            +
                        top_pixel bind(file, :top_pixel)
         | 
| 45 45 | 
             
                        drop_target(DND::DROP_COPY) {
         | 
| 46 46 | 
             
                          transfer [TextTransfer.getInstance].to_java(Transfer)
         | 
| 47 47 | 
             
                          on_drag_enter { |event|
         | 
| @@ -57,12 +57,21 @@ module Glimmer | |
| 57 57 |  | 
| 58 58 | 
             
                        on_focus_lost {
         | 
| 59 59 | 
             
                          file&.write_dirty_content
         | 
| 60 | 
            -
                        }
         | 
| 61 | 
            -
             | 
| 60 | 
            +
                        }              
         | 
| 61 | 
            +
                        on_verify_key { |key_event|
         | 
| 62 62 | 
             
                          if (Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY, :shift) && extract_char(key_event) == 'z') || (key_event.stateMask == swt(COMMAND_KEY) && extract_char(key_event) == 'y')                
         | 
| 63 63 | 
             
                            key_event.doit = !Command.redo(file)
         | 
| 64 | 
            +
                          elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY, :shift) && extract_char(key_event) == 'r'
         | 
| 65 | 
            +
                            Dir.local_dir.selected_child.write_dirty_content              
         | 
| 66 | 
            +
                            begin
         | 
| 67 | 
            +
                              load Dir.local_dir.selected_child.path
         | 
| 68 | 
            +
                            rescue => e
         | 
| 69 | 
            +
                              puts e.full_message
         | 
| 70 | 
            +
                            end
         | 
| 64 71 | 
             
                          elsif key_event.stateMask == swt(COMMAND_KEY) && extract_char(key_event) == 'z'
         | 
| 65 72 | 
             
                            key_event.doit = !Command.undo(file)
         | 
| 73 | 
            +
                          elsif key_event.stateMask == swt(COMMAND_KEY) && extract_char(key_event) == 'a'
         | 
| 74 | 
            +
                            key_event.widget.selectAll
         | 
| 66 75 | 
             
                          elsif key_event.stateMask == swt(COMMAND_KEY) && extract_char(key_event) == '/'
         | 
| 67 76 | 
             
                            Command.do(file, :comment_line!)
         | 
| 68 77 | 
             
                            key_event.doit = false
         | 
| @@ -105,13 +114,13 @@ module Glimmer | |
| 105 114 | 
             
                          end
         | 
| 106 115 | 
             
                        }
         | 
| 107 116 | 
             
                        on_verify_text { |verify_event|
         | 
| 108 | 
            -
                           | 
| 109 | 
            -
                          case  | 
| 110 | 
            -
                          when  | 
| 117 | 
            +
                          # TODO convert these into File commands to support Undo/Redo                             
         | 
| 118 | 
            +
                          case verify_event.text
         | 
| 119 | 
            +
                          when "\n"
         | 
| 111 120 | 
             
                            if file.selection_count.to_i == 0
         | 
| 112 121 | 
             
                              verify_event.text += file.current_line_indentation
         | 
| 113 122 | 
             
                            end
         | 
| 114 | 
            -
                          when  | 
| 123 | 
            +
                          when "\t"
         | 
| 115 124 | 
             
                            if file.selection_count.to_i > 0
         | 
| 116 125 | 
             
                              Command.do(file, :indent!)
         | 
| 117 126 | 
             
                              verify_event.doit = false
         | 
    
        metadata
    CHANGED
    
    | @@ -1,21 +1,21 @@ | |
| 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.4.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-10- | 
| 11 | 
            +
            date: 2020-10-23 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: 4.17.2 | 
| 18 | 
            +
                    version: 4.17.4.2
         | 
| 19 19 | 
             
                - - "<"
         | 
| 20 20 | 
             
                  - !ruby/object:Gem::Version
         | 
| 21 21 | 
             
                    version: 5.0.0.0
         | 
| @@ -26,7 +26,7 @@ dependencies: | |
| 26 26 | 
             
                requirements:
         | 
| 27 27 | 
             
                - - ">="
         | 
| 28 28 | 
             
                  - !ruby/object:Gem::Version
         | 
| 29 | 
            -
                    version: 4.17.2 | 
| 29 | 
            +
                    version: 4.17.4.2
         | 
| 30 30 | 
             
                - - "<"
         | 
| 31 31 | 
             
                  - !ruby/object:Gem::Version
         | 
| 32 32 | 
             
                    version: 5.0.0.0
         |