ruco 0.0.14 → 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,5 +1,7 @@
1
1
  source :rubygems
2
2
 
3
+ gem 'clipboard'
4
+
3
5
  group :dev do # not development <-> would add unneeded development dependencies in gemspec
4
6
  gem 'rake'
5
7
  gem 'rspec', '~>2'
data/Gemfile.lock CHANGED
@@ -1,6 +1,8 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
+ clipboard (0.9.3)
5
+ zucker (>= 8)
4
6
  diff-lcs (1.1.2)
5
7
  git (1.2.5)
6
8
  jeweler (1.5.2)
@@ -18,11 +20,13 @@ GEM
18
20
  rspec-mocks (2.0.1)
19
21
  rspec-core (~> 2.0.1)
20
22
  rspec-expectations (~> 2.0.1)
23
+ zucker (8)
21
24
 
22
25
  PLATFORMS
23
26
  ruby
24
27
 
25
28
  DEPENDENCIES
29
+ clipboard
26
30
  jeweler
27
31
  rake
28
32
  rspec (~> 2)
data/Readme.md CHANGED
@@ -13,6 +13,8 @@ Finished:
13
13
  - find / go to line
14
14
  - delete line
15
15
  - configuration via `~/.ruco.rb`
16
+ - keeps indentation
17
+ - paste from clipboard (default: Ctrl+v)
16
18
 
17
19
  Install
18
20
  =======
@@ -58,9 +60,9 @@ TIPS
58
60
 
59
61
  TODO
60
62
  =====
63
+ - selecting -> delete / overwrite / copy / cut
61
64
  - support typing unicode like äöß etc (rework size / make strings utf8-aware)
62
65
  - smart staying at end of line/column when changing line
63
- - indentation + paste support
64
66
  - warnings / messages
65
67
  - syntax highlighting
66
68
  - support more key-combos/codes in keyboard.rb
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.14
1
+ 0.0.15
data/lib/ruco.rb CHANGED
@@ -15,6 +15,8 @@ require 'ruco/text_area'
15
15
  require 'ruco/text_field'
16
16
 
17
17
  module Ruco
18
+ autoload :Clipboard, 'clipboard' # can crash when loaded -> load if needed
19
+
18
20
  VERSION = File.read( File.join(File.dirname(__FILE__),'..','VERSION') ).strip
19
21
  TAB_SIZE = 2
20
22
 
@@ -84,6 +84,10 @@ module Ruco
84
84
  def setup_actions
85
85
  @actions = {}
86
86
 
87
+ action :paste do
88
+ editor.insert(Clipboard.paste('clipboard'))
89
+ end
90
+
87
91
  action :save do
88
92
  editor.save
89
93
  end
@@ -119,6 +123,7 @@ module Ruco
119
123
  bind :"Ctrl+g", :go_to_line
120
124
  bind :"Ctrl+f", :find
121
125
  bind :"Ctrl+d", :delete_line
126
+ bind :"Ctrl+v", :paste
122
127
  end
123
128
 
124
129
  def load_user_config
@@ -49,6 +49,9 @@ module Ruco
49
49
 
50
50
  def insert(text)
51
51
  text = tabs_to_spaces(text)
52
+ if text == "\n"
53
+ text = text + lines[@line].match(/^\s*/)[0]
54
+ end
52
55
  insert_into_content cursor_index, text
53
56
  move_according_to_insert(text)
54
57
  end
data/ruco.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ruco}
8
- s.version = "0.0.14"
8
+ s.version = "0.0.15"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Michael Grosser"]
@@ -65,9 +65,12 @@ Gem::Specification.new do |s|
65
65
  s.specification_version = 3
66
66
 
67
67
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
68
+ s.add_runtime_dependency(%q<clipboard>, [">= 0"])
68
69
  else
70
+ s.add_dependency(%q<clipboard>, [">= 0"])
69
71
  end
70
72
  else
73
+ s.add_dependency(%q<clipboard>, [">= 0"])
71
74
  end
72
75
  end
73
76
 
@@ -9,6 +9,10 @@ describe Ruco::Application do
9
9
  File.open(@file,'w'){|f| f.write(content) }
10
10
  end
11
11
 
12
+ def editor_part(view)
13
+ view.naive_split("\n")[1..-2].join("\n")
14
+ end
15
+
12
16
  let(:app){ Ruco::Application.new(@file, :lines => 5, :columns => 10) }
13
17
  let(:status){ "Ruco #{Ruco::VERSION} -- spec/temp.txt \n" }
14
18
  let(:command){ "^W Exit" }
@@ -101,6 +105,26 @@ describe Ruco::Application do
101
105
  end
102
106
  end
103
107
 
108
+ describe 'indentation' do
109
+ it "does not extra-indent when pasting" do
110
+ write('')
111
+ Ruco.class_eval "Clipboard.copy('ab\n cd\n ef')"
112
+ app.key(:tab)
113
+ app.key(:tab)
114
+ app.key(:'Ctrl+v') # paste
115
+ editor_part(app.view).should == " ab\n cd\n ef"
116
+ end
117
+
118
+ it "indents when typing" do
119
+ write('')
120
+ app.key(:tab)
121
+ app.key(:tab)
122
+ app.key(:enter)
123
+ app.key('a')
124
+ editor_part(app.view).should == " \n a\n"
125
+ end
126
+ end
127
+
104
128
  describe '.ruco.rb' do
105
129
  it "loads it and can use the bound keys" do
106
130
  Tempfile.string_as_file("Ruco.configure{ bind(:'Ctrl+e'){ @editor.insert('TEST') } }") do |file|
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruco
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 1
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 14
10
- version: 0.0.14
9
+ - 15
10
+ version: 0.0.15
11
11
  platform: ruby
12
12
  authors:
13
13
  - Michael Grosser
@@ -17,8 +17,21 @@ cert_chain: []
17
17
 
18
18
  date: 2011-01-16 00:00:00 +01:00
19
19
  default_executable: ruco
20
- dependencies: []
21
-
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ requirement: &id001 !ruby/object:Gem::Requirement
23
+ none: false
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ hash: 3
28
+ segments:
29
+ - 0
30
+ version: "0"
31
+ prerelease: false
32
+ version_requirements: *id001
33
+ type: :runtime
34
+ name: clipboard
22
35
  description:
23
36
  email: michael@grosser.it
24
37
  executables: