glimmer-cs-gladiator 0.4.1 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,12 +3,12 @@ module Glimmer
3
3
  class TextEditor
4
4
  include Glimmer::UI::CustomWidget
5
5
 
6
- options :file
6
+ options :file, :project_dir
7
7
 
8
8
  attr_reader :text_proxy, :text_widget
9
9
 
10
10
  before_body {
11
- @is_code_file = file.path.end_with?('.rb')
11
+ @is_code_file = file.scratchpad? || file.path.end_with?('.rb')
12
12
  @text_widget = @is_code_file ? 'code_text' : 'styled_text'
13
13
  }
14
14
 
@@ -21,13 +21,19 @@ module Glimmer
21
21
  composite {
22
22
  layout_data :fill, :fill, true, true
23
23
  grid_layout 2, false
24
- @line_numbers_text = send(@text_widget, :multi, :border) {
24
+ @line_numbers_text = styled_text(:multi, :wrap, :border) {
25
25
  layout_data(:right, :fill, false, true)
26
26
  font name: 'Consolas', height: OS.mac? ? 15 : 12
27
27
  background color(:widget_background)
28
- foreground rgb(75, 75, 75)
29
- text bind(file, 'line_numbers_content')
30
- top_pixel bind(file, 'top_pixel', read_only: true)
28
+ foreground rgb(0, 0, 250)
29
+ text bind(self, 'file.line_numbers_content')
30
+ top_pixel bind(self, 'file.top_pixel', read_only: true)
31
+ top_margin 5
32
+ right_margin 5
33
+ bottom_margin 5
34
+ left_margin 5
35
+ editable false
36
+ alignment swt(:right)
31
37
  on_focus_gained {
32
38
  @text&.swt_widget.setFocus
33
39
  }
@@ -43,10 +49,14 @@ module Glimmer
43
49
  layout_data :fill, :fill, true, true
44
50
  font name: 'Consolas', height: OS.mac? ? 15 : 12
45
51
  foreground rgb(75, 75, 75)
46
- text bind(file, :content)
52
+ text bind(self, 'file.content')
47
53
  focus true
48
- selection bind(file, :selection)
49
- top_pixel bind(file, 'top_pixel')
54
+ selection bind(self, 'file.selection')
55
+ top_pixel bind(self, 'file.top_pixel')
56
+ top_margin 5
57
+ right_margin 5
58
+ bottom_margin 5
59
+ left_margin 5
50
60
  drop_target(DND::DROP_COPY) {
51
61
  transfer [TextTransfer.getInstance].to_java(Transfer)
52
62
  on_drag_enter { |event|
@@ -54,29 +64,30 @@ module Glimmer
54
64
  }
55
65
  on_drop { |event|
56
66
  Gladiator.drag_and_drop = true
57
- Dir.local_dir.selected_child = nil
58
- Dir.local_dir.selected_child_path = event.data
67
+ project_dir.selected_child = nil
68
+ project_dir.selected_child_path = event.data
59
69
  Gladiator.drag = false
60
70
  }
61
- }
71
+ }
62
72
 
63
73
  on_focus_lost {
64
74
  file&.write_dirty_content
65
- }
75
+ }
66
76
  on_verify_key { |key_event|
67
- 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')
77
+ 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')
68
78
  key_event.doit = !Command.redo(file)
69
79
  elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY, :shift) && extract_char(key_event) == 'r'
70
- Dir.local_dir.selected_child.write_dirty_content
71
- begin
72
- load Dir.local_dir.selected_child.path
73
- rescue => e
74
- puts e.full_message
75
- end
80
+ project_dir.selected_child.run
76
81
  elsif key_event.stateMask == swt(COMMAND_KEY) && extract_char(key_event) == 'z'
77
82
  key_event.doit = !Command.undo(file)
78
83
  elsif key_event.stateMask == swt(COMMAND_KEY) && extract_char(key_event) == 'a'
79
84
  key_event.widget.selectAll
85
+ elsif !OS.windows? && key_event.stateMask == swt(:ctrl) && extract_char(key_event) == 'a'
86
+ Command.do(file, :start_of_line)
87
+ key_event.doit = false
88
+ elsif !OS.windows? && key_event.stateMask == swt(:ctrl) && extract_char(key_event) == 'e'
89
+ Command.do(file, :end_of_line)
90
+ key_event.doit = false
80
91
  elsif key_event.stateMask == swt(COMMAND_KEY) && extract_char(key_event) == '/'
81
92
  Command.do(file, :comment_line!)
82
93
  key_event.doit = false
@@ -119,19 +130,15 @@ module Glimmer
119
130
  end
120
131
  }
121
132
  on_verify_text { |verify_event|
122
- # TODO convert these into File commands to support Undo/Redo
133
+ # TODO convert these into File commands to support Undo/Redo
123
134
  case verify_event.text
124
135
  when "\n"
125
136
  if file.selection_count.to_i == 0
126
137
  verify_event.text += file.current_line_indentation
127
138
  end
128
139
  when "\t"
129
- if file.selection_count.to_i > 0
130
- Command.do(file, :indent!)
131
- verify_event.doit = false
132
- else
133
- verify_event.text = ' '
134
- end
140
+ Command.do(file, :indent!)
141
+ verify_event.doit = false
135
142
  end
136
143
  }
137
144
  }
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.1
4
+ version: 0.5.4
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-24 00:00:00.000000000 Z
11
+ date: 2020-11-20 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.5.0
18
+ version: 4.17.10.0
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.5.0
29
+ version: 4.17.10.0
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: 5.0.0.0
@@ -49,7 +49,7 @@ dependencies:
49
49
  requirements:
50
50
  - - "~>"
51
51
  - !ruby/object:Gem::Version
52
- version: 1.3.4
52
+ version: 1.3.5
53
53
  name: clipboard
54
54
  prerelease: false
55
55
  type: :runtime
@@ -57,7 +57,7 @@ dependencies:
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: 1.3.4
60
+ version: 1.3.5
61
61
  - !ruby/object:Gem::Dependency
62
62
  requirement: !ruby/object:Gem::Requirement
63
63
  requirements: