fidgit 0.1.3 → 0.1.4
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.
- data/fidgit.gemspec +4 -2
- data/lib/fidgit.rb +1 -0
- data/lib/fidgit/elements/text_area.rb +46 -0
- data/lib/fidgit/states/gui_state.rb +5 -1
- data/lib/fidgit/version.rb +1 -1
- metadata +32 -11
- data/lib/fidgit/clipboard.rb +0 -23
data/fidgit.gemspec
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
$:.
|
2
|
+
$:.unshift File.expand_path("../lib", __FILE__)
|
3
3
|
require "fidgit/version"
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
@@ -20,9 +20,11 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
21
21
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
22
22
|
s.require_paths = ["lib"]
|
23
|
-
|
23
|
+
|
24
24
|
s.add_dependency('gosu', '~> 0.7.32')
|
25
25
|
s.add_dependency('chingu', '~> 0.9rc5')
|
26
|
+
s.add_dependency('clipboard', '~> 0.9.8')
|
27
|
+
s.add_dependency('ffi', '~> 1.0.9') # if RUBY_PLATFORM =~ /mswin32|mingw32/ # Required by clipboard on Windows.
|
26
28
|
s.add_development_dependency('rspec', '~> 2.1.0')
|
27
29
|
s.add_development_dependency('texplay', '~> 0.3.5')
|
28
30
|
end
|
data/lib/fidgit.rb
CHANGED
@@ -46,6 +46,27 @@ module Fidgit
|
|
46
46
|
text[selection_range]
|
47
47
|
end
|
48
48
|
|
49
|
+
# Sets the text within the selection. The caret will be placed at the end of the inserted text.
|
50
|
+
#
|
51
|
+
# @param [String] str Text to insert.
|
52
|
+
# @return [String] The new selection text.
|
53
|
+
def selection_text=(str)
|
54
|
+
from = [@text_input.selection_start, @text_input.caret_pos].min
|
55
|
+
new_length = str.length
|
56
|
+
|
57
|
+
full_text = text
|
58
|
+
full_text[selection_range] = str.encode('UTF-8', undef: :replace)
|
59
|
+
@text_input.text = full_text
|
60
|
+
|
61
|
+
@text_input.selection_start = @text_input.caret_pos = from + new_length
|
62
|
+
|
63
|
+
recalc # This may roll back the text if it is too long!
|
64
|
+
|
65
|
+
publish :changed, self.text
|
66
|
+
|
67
|
+
str
|
68
|
+
end
|
69
|
+
|
49
70
|
# Position of the caret.
|
50
71
|
#
|
51
72
|
# @return [Integer] Number in range 0..text.length
|
@@ -342,6 +363,31 @@ module Fidgit
|
|
342
363
|
nil
|
343
364
|
end
|
344
365
|
|
366
|
+
public
|
367
|
+
# Cut the selection and copy it to the clipboard.
|
368
|
+
def cut
|
369
|
+
str = selection_text
|
370
|
+
unless selection_text.empty?
|
371
|
+
Clipboard.copy str
|
372
|
+
self.selection_text = ''
|
373
|
+
end
|
374
|
+
end
|
375
|
+
|
376
|
+
public
|
377
|
+
# Copy the selection to the clipboard.
|
378
|
+
def copy
|
379
|
+
str = selection_text
|
380
|
+
unless selection_text.empty?
|
381
|
+
Clipboard.copy str
|
382
|
+
end
|
383
|
+
end
|
384
|
+
|
385
|
+
public
|
386
|
+
# Paste the contents of the clipboard into the TextArea.
|
387
|
+
def paste
|
388
|
+
self.selection_text = Clipboard.paste
|
389
|
+
end
|
390
|
+
|
345
391
|
protected
|
346
392
|
# Use block as an event handler.
|
347
393
|
def post_init_block(&block)
|
@@ -81,7 +81,11 @@ module Fidgit
|
|
81
81
|
released_right_mouse_button: ->{ redirect_released_mouse_button(:right) },
|
82
82
|
|
83
83
|
mouse_wheel_up: :redirect_mouse_wheel_up,
|
84
|
-
mouse_wheel_down: :redirect_mouse_wheel_down
|
84
|
+
mouse_wheel_down: :redirect_mouse_wheel_down,
|
85
|
+
|
86
|
+
x: -> { if @focus and (holding_any?(:left_control, :right_control)) then @focus.cut end },
|
87
|
+
c: -> { if @focus and (holding_any?(:left_control, :right_control)) then @focus.copy end },
|
88
|
+
v: -> { if @focus and (holding_any?(:left_control, :right_control)) then @focus.paste end }
|
85
89
|
)
|
86
90
|
end
|
87
91
|
|
data/lib/fidgit/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fidgit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,12 +9,12 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-06-
|
12
|
+
date: 2011-06-14 00:00:00.000000000 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: gosu
|
17
|
-
requirement: &
|
17
|
+
requirement: &25820988 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ~>
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: 0.7.32
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *25820988
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: chingu
|
28
|
-
requirement: &
|
28
|
+
requirement: &25820712 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
@@ -33,10 +33,32 @@ dependencies:
|
|
33
33
|
version: 0.9rc5
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *25820712
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: clipboard
|
39
|
+
requirement: &25820436 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ~>
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: 0.9.8
|
45
|
+
type: :runtime
|
46
|
+
prerelease: false
|
47
|
+
version_requirements: *25820436
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: ffi
|
50
|
+
requirement: &25820160 !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ~>
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 1.0.9
|
56
|
+
type: :runtime
|
57
|
+
prerelease: false
|
58
|
+
version_requirements: *25820160
|
37
59
|
- !ruby/object:Gem::Dependency
|
38
60
|
name: rspec
|
39
|
-
requirement: &
|
61
|
+
requirement: &25819884 !ruby/object:Gem::Requirement
|
40
62
|
none: false
|
41
63
|
requirements:
|
42
64
|
- - ~>
|
@@ -44,10 +66,10 @@ dependencies:
|
|
44
66
|
version: 2.1.0
|
45
67
|
type: :development
|
46
68
|
prerelease: false
|
47
|
-
version_requirements: *
|
69
|
+
version_requirements: *25819884
|
48
70
|
- !ruby/object:Gem::Dependency
|
49
71
|
name: texplay
|
50
|
-
requirement: &
|
72
|
+
requirement: &25819608 !ruby/object:Gem::Requirement
|
51
73
|
none: false
|
52
74
|
requirements:
|
53
75
|
- - ~>
|
@@ -55,7 +77,7 @@ dependencies:
|
|
55
77
|
version: 0.3.5
|
56
78
|
type: :development
|
57
79
|
prerelease: false
|
58
|
-
version_requirements: *
|
80
|
+
version_requirements: *25819608
|
59
81
|
description: Fidgit is a GUI library built on Gosu/Chingu
|
60
82
|
email:
|
61
83
|
- bil.bagpuss@gmail.com
|
@@ -93,7 +115,6 @@ files:
|
|
93
115
|
- fidgit.gemspec
|
94
116
|
- lib/fidgit.rb
|
95
117
|
- lib/fidgit/chingu_ext/window.rb
|
96
|
-
- lib/fidgit/clipboard.rb
|
97
118
|
- lib/fidgit/cursor.rb
|
98
119
|
- lib/fidgit/elements/button.rb
|
99
120
|
- lib/fidgit/elements/color_picker.rb
|
data/lib/fidgit/clipboard.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module Fidgit
|
4
|
-
class Clipboard
|
5
|
-
# Items held in the clipboard.
|
6
|
-
attr_reader :items
|
7
|
-
|
8
|
-
def empty?; @items.empty?; end
|
9
|
-
|
10
|
-
def initialize
|
11
|
-
@items = []
|
12
|
-
end
|
13
|
-
|
14
|
-
# Copy items into the clipboard.
|
15
|
-
#
|
16
|
-
# @param [Array] items Items to copy
|
17
|
-
def copy(items)
|
18
|
-
@items = items.to_a.dup
|
19
|
-
|
20
|
-
nil
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|