redcar 0.3.4.1 → 0.3.4.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -16,6 +16,10 @@ Internal changes:
16
16
  * Textmate plugin for dealing with Textmate bundles.
17
17
  * Application focus in/out events.
18
18
 
19
+ Fixes:
20
+
21
+ * Respects Windows style line delimiters
22
+
19
23
  New contributors:
20
24
 
21
25
  * Aaron McLeod
data/Rakefile CHANGED
@@ -75,7 +75,7 @@ end
75
75
 
76
76
  spec = Gem::Specification.new do |s|
77
77
  s.name = "redcar"
78
- s.version = "0.3.4.1"
78
+ s.version = "0.3.4.2"
79
79
  s.summary = "A JRuby text editor."
80
80
  s.author = "Daniel Lucraft"
81
81
  s.email = "dan@fluentradical.com"
@@ -7,7 +7,7 @@ module Redcar
7
7
 
8
8
  def after_newline(line_ix)
9
9
  if line_ix > 0
10
- previous_line = document.get_line(line_ix - 1).gsub("\n", "")
10
+ previous_line = document.get_line(line_ix - 1).gsub(document.delim, "")
11
11
  whitespace_prefix = whitespace_prefix(previous_line)
12
12
  offset = document.offset_at_line(line_ix)
13
13
  document.insert(offset, whitespace_prefix)
@@ -64,7 +64,7 @@ describe Redcar::Plugin::Storage do
64
64
  storage['a'].should == 'b'
65
65
  sleep 1 # windows doesn't have finer granularity than this
66
66
  File.open(storage.send(:path), 'w') do |f|
67
- f.write "---
67
+ f.write "---
68
68
  a: new"
69
69
  end
70
70
  storage['a'].should == 'new'
@@ -44,8 +44,8 @@ module Redcar
44
44
 
45
45
  def self.move_left_offset(edit_view)
46
46
  doc = edit_view.document
47
- return 0 if doc.cursor_offset == 0
48
- return doc.cursor_offset - 1 if doc.cursor_line_offset == 0
47
+ return 0 if doc.cursor_offset == 0
48
+ return doc.cursor_offset - doc.delim.length if doc.cursor_line_offset == 0
49
49
  if edit_view.soft_tabs?
50
50
  line = doc.get_line(doc.cursor_line)
51
51
  width = edit_view.tab_width
@@ -96,7 +96,7 @@ module Redcar
96
96
  end
97
97
  end
98
98
  @controllers[Controller::NewlineCallback].each do |controller|
99
- if text == "\n" or text == "\r\n"
99
+ if text == line_delimiter
100
100
  rescue_document_controller_error(controller) do
101
101
  controller.after_newline(line_at_offset(start_offset) + 1)
102
102
  end
@@ -129,6 +129,17 @@ module Redcar
129
129
  controller.single_line?
130
130
  end
131
131
 
132
+ # Returns the line delimiter for this document. Either
133
+ # \n or \r\n. It will attempt to detect the delimiter from the document
134
+ # or it will default to the platform delimiter.
135
+ #
136
+ # @return [String]
137
+ def line_delimiter
138
+ controller.get_line_delimiter
139
+ end
140
+
141
+ alias :delim :line_delimiter
142
+
132
143
  # Is there any text selected? (Or equivalently, is the length
133
144
  # of the selection equal to 0)
134
145
  #
@@ -142,7 +153,7 @@ module Redcar
142
153
  # @param [Integer] offset character offset from the start of the document
143
154
  # @param [String] text text to insert
144
155
  def insert(offset, text)
145
- text = text.gsub("\n", "") if single_line?
156
+ text = text.gsub(delim, "") if single_line?
146
157
  replace(offset, 0, text)
147
158
  end
148
159
 
@@ -167,7 +178,7 @@ module Redcar
167
178
  # @param [Integer] length length of text to replace
168
179
  # @param [String] text replacement text
169
180
  def replace(offset, length, text)
170
- text = text.gsub("\n", "") if single_line?
181
+ text = text.gsub(delim, "") if single_line?
171
182
  controller.replace(offset, length, text)
172
183
  end
173
184
 
@@ -359,14 +370,14 @@ module Redcar
359
370
  replace(start_offset, end_offset - start_offset, text)
360
371
  end
361
372
 
362
- # Get the offset at the end of a given line, *before* the newline character.
373
+ # Get the offset at the end of a given line, *before* the line delimiter.
363
374
  #
364
375
  # @param [Integer] line_ix a zero-based line index
365
376
  def offset_at_inner_end_of_line(line_ix)
366
377
  if line_ix == line_count - 1
367
378
  length
368
379
  else
369
- offset_at_line(line_ix + 1) - 1
380
+ offset_at_line(line_ix + 1) - delim.length
370
381
  end
371
382
  end
372
383
 
@@ -33,6 +33,10 @@ module Redcar
33
33
  jface_document.get_number_of_lines
34
34
  end
35
35
 
36
+ def get_line_delimiter
37
+ styledText.get_line_delimiter
38
+ end
39
+
36
40
  def line_at_offset(offset)
37
41
  jface_document.get_line_of_offset(offset)
38
42
  end
@@ -55,7 +55,7 @@ module Redcar
55
55
  #
56
56
  # @return [String]
57
57
  def title
58
- @path.split("/").last
58
+ @path.split(/\/|\\/).last
59
59
  end
60
60
 
61
61
  private
@@ -544,7 +544,7 @@ module Redcar
544
544
 
545
545
  link "Cmd+Shift+R", PluginManagerUi::ReloadLastReloadedCommand
546
546
 
547
- link "Cmd+Shift+S", Snippets::OpenSnippetExplorer
547
+ link "Cmd+Alt+S", Snippets::OpenSnippetExplorer
548
548
  #Textmate.attach_keybindings(self, :osx)
549
549
  end
550
550
 
@@ -586,7 +586,7 @@ module Redcar
586
586
  link "Ctrl+Page Down", SwitchTabUpCommand
587
587
  link "Ctrl+Shift+R", PluginManagerUi::ReloadLastReloadedCommand
588
588
 
589
- link "Ctrl+Shift+S", Snippets::OpenSnippetExplorer
589
+ link "Ctrl+Alt+S", Snippets::OpenSnippetExplorer
590
590
  #Textmate.attach_keybindings(self, :linux)
591
591
 
592
592
  end
@@ -106,13 +106,13 @@ module Redcar
106
106
  orig_stdout = $stdout
107
107
  stdout_handler = StringIO.new
108
108
  $stdout = stdout_handler
109
-
110
- result = eval(command, @binding)
111
-
112
- $stdout.rewind
113
- @output = $stdout.read
114
-
115
- $stdout = orig_stdout
109
+ begin
110
+ result = eval(command, @binding)
111
+ ensure
112
+ $stdout.rewind
113
+ @output = $stdout.read
114
+ $stdout = orig_stdout
115
+ end
116
116
  result
117
117
  end
118
118
  end
@@ -9,7 +9,9 @@ module Redcar
9
9
  current_scope = nil
10
10
  if document = Redcar::EditView.focussed_edit_view_document
11
11
  line = document.get_line(document.cursor_line)
12
- line = line[0..-2] if line[-1..-1] == "\n"
12
+ if line =~ /#{document.delim}$/
13
+ line = line[0..(-1*document.delim.length - 1)]
14
+ end
13
15
  @env['TM_CURRENT_LINE'] = line
14
16
  @env['TM_LINE_INDEX'] = document.cursor_line_offset.to_s
15
17
  @env['TM_LINE_NUMBER'] = (document.cursor_line + 1).to_s
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redcar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4.1
4
+ version: 0.3.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Lucraft
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-03-07 00:00:00 +00:00
12
+ date: 2010-03-08 00:00:00 +00:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency