rum 0.0.1-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. data/CHANGELOG +3 -0
  2. data/README +30 -0
  3. data/Rakefile +134 -0
  4. data/bin/rum-client +124 -0
  5. data/doc/basic.rb +10 -0
  6. data/doc/doc.html +602 -0
  7. data/doc/example.rb +59 -0
  8. data/doc/reference.rb +415 -0
  9. data/doc/resources/bg.png +0 -0
  10. data/doc/resources/bottom.png +0 -0
  11. data/doc/resources/build.rb +235 -0
  12. data/doc/resources/doc.haml +167 -0
  13. data/doc/resources/emacs-auto-completion.png +0 -0
  14. data/doc/resources/flash.png +0 -0
  15. data/doc/resources/highlight.css +94 -0
  16. data/doc/resources/intro.rb +17 -0
  17. data/doc/resources/left.png +0 -0
  18. data/doc/resources/logo.png +0 -0
  19. data/doc/resources/screen.css +420 -0
  20. data/doc/resources/screenshot.png +0 -0
  21. data/doc/resources/top.png +0 -0
  22. data/ext/mac/keyboard_hook/English.lproj/InfoPlist.strings +0 -0
  23. data/ext/mac/keyboard_hook/Event.h +17 -0
  24. data/ext/mac/keyboard_hook/Event.m +18 -0
  25. data/ext/mac/keyboard_hook/EventTap.h +11 -0
  26. data/ext/mac/keyboard_hook/EventTap.m +77 -0
  27. data/ext/mac/keyboard_hook/Info.plist +26 -0
  28. data/ext/mac/keyboard_hook/KeyboardHook.xcodeproj/TemplateIcon.icns +0 -0
  29. data/ext/mac/keyboard_hook/KeyboardHook.xcodeproj/project.pbxproj +323 -0
  30. data/ext/mac/keyboard_hook/KeyboardHook_Prefix.pch +7 -0
  31. data/ext/mac/keyboard_hook/version.plist +16 -0
  32. data/ext/windows/keyboard_hook/extconf.rb +2 -0
  33. data/ext/windows/keyboard_hook/keyboard_hook.c +126 -0
  34. data/ext/windows/system/autohotkey_stuff.c +255 -0
  35. data/ext/windows/system/autohotkey_stuff.h +2 -0
  36. data/ext/windows/system/clipboard_watcher.c +58 -0
  37. data/ext/windows/system/clipboard_watcher.h +2 -0
  38. data/ext/windows/system/extconf.rb +3 -0
  39. data/ext/windows/system/input_box.c +239 -0
  40. data/ext/windows/system/input_box.h +4 -0
  41. data/ext/windows/system/system.c +273 -0
  42. data/lib/rum.rb +4 -0
  43. data/lib/rum/apps.rb +4 -0
  44. data/lib/rum/barrel.rb +157 -0
  45. data/lib/rum/barrel/emacs.rb +44 -0
  46. data/lib/rum/barrel/emacs_client.rb +74 -0
  47. data/lib/rum/core.rb +125 -0
  48. data/lib/rum/dsl.rb +109 -0
  49. data/lib/rum/gui.rb +93 -0
  50. data/lib/rum/help.rb +128 -0
  51. data/lib/rum/hotkey_core.rb +479 -0
  52. data/lib/rum/mac.rb +18 -0
  53. data/lib/rum/mac/app.rb +4 -0
  54. data/lib/rum/mac/apps.rb +19 -0
  55. data/lib/rum/mac/gui.rb +26 -0
  56. data/lib/rum/mac/gui/growl.rb +54 -0
  57. data/lib/rum/mac/irb/completion.rb +207 -0
  58. data/lib/rum/mac/keyboard_hook.rb +73 -0
  59. data/lib/rum/mac/layouts.rb +146 -0
  60. data/lib/rum/mac/system.rb +45 -0
  61. data/lib/rum/remote.rb +48 -0
  62. data/lib/rum/server.rb +92 -0
  63. data/lib/rum/windows.rb +23 -0
  64. data/lib/rum/windows/app.rb +72 -0
  65. data/lib/rum/windows/apps.rb +25 -0
  66. data/lib/rum/windows/gui.rb +116 -0
  67. data/lib/rum/windows/keyboard.rb +80 -0
  68. data/lib/rum/windows/keyboard_hook.rb +20 -0
  69. data/lib/rum/windows/keyboard_hook.so +0 -0
  70. data/lib/rum/windows/layouts.rb +232 -0
  71. data/lib/rum/windows/system.rb +310 -0
  72. data/lib/rum/windows/system.so +0 -0
  73. data/lib/rum/windows/system_foreign_functions.rb +129 -0
  74. data/rum.gemspec +14 -0
  75. metadata +156 -0
@@ -0,0 +1,18 @@
1
+ require 'rum/mac/system'
2
+ require 'rum/mac/keyboard_hook'
3
+ require 'rum/mac/gui'
4
+ require 'rum/mac/layouts'
5
+ require 'rum/mac/app'
6
+
7
+ module Rum
8
+ Platform = :mac
9
+
10
+ def self.restart_platform_specific
11
+ Rum::Server.close_connections
12
+ exec(RUBY_ENGINE, $PROGRAM_NAME)
13
+ end
14
+
15
+ module Keyboard
16
+ # not yet implemented
17
+ end
18
+ end
@@ -0,0 +1,4 @@
1
+ module Rum
2
+ class App
3
+ end
4
+ end
@@ -0,0 +1,19 @@
1
+ Emacs = App.new
2
+ require 'rum/barrel/emacs'
3
+ class << Emacs
4
+ def activate
5
+ System.script 'tell application "Emacs"
6
+ activate
7
+ end tell'
8
+ end
9
+ end
10
+
11
+ Textmate = App.new
12
+ class << Textmate
13
+ def open_file(path, line=nil)
14
+ args = []
15
+ args.concat ['-l', line.to_s] if line
16
+ args << path
17
+ system('mate', *args)
18
+ end
19
+ end
@@ -0,0 +1,26 @@
1
+ module Rum
2
+ module Gui
3
+ autoload :Growl, 'rum/mac/gui/growl'
4
+
5
+ def open_file path, line=nil
6
+ NSWorkspace.sharedWorkspace.openFile(File.expand_path(path))
7
+ end
8
+
9
+ def goto path
10
+ # reveal in finder
11
+ System.start '-R', path
12
+ end
13
+
14
+ private
15
+
16
+ def browse_backend url
17
+ url = NSURL.URLWithString(url)
18
+ NSWorkspace.sharedWorkspace.openURL(url)
19
+ end
20
+
21
+ binary = File.join(File.dirname(__FILE__),
22
+ 'gui/CocoaDialog.app/Contents/MacOS/CocoaDialog')
23
+ CocoaDialog.setup binary
24
+ use CocoaDialog
25
+ end
26
+ end
@@ -0,0 +1,54 @@
1
+ module Rum
2
+ module Gui
3
+ module Growl
4
+ class Notifier
5
+ def initialize application_name, notification_name
6
+ @application_name = application_name
7
+ @notification_name = notification_name
8
+ @callbacks = {}
9
+ GrowlApplicationBridge.setGrowlDelegate(self)
10
+ end
11
+
12
+ def registrationDictionaryForGrowl
13
+ notifications = [@notification_name]
14
+ { TicketVersion: 1, AllNotifications: notifications,
15
+ DefaultNotifications: notifications, ApplicationId: ''}
16
+ end
17
+
18
+ def applicationNameForGrowl
19
+ @application_name
20
+ end
21
+
22
+ def growlNotificationWasClicked click_context
23
+ @callbacks[click_context].call
24
+ end
25
+
26
+ def notify(title, description, sticky, callback)
27
+ if callback
28
+ click_context = callback.object_id
29
+ @callbacks[click_context] = callback
30
+ end
31
+ GrowlApplicationBridge.notifyWithTitle(title.to_s,
32
+ description: description.to_s,
33
+ notificationName: @notification_name,
34
+ iconData: nil,
35
+ priority: 0,
36
+ isSticky: !!sticky,
37
+ clickContext: click_context)
38
+ end
39
+ end
40
+
41
+ def self.auto_setup
42
+ framework File.join(File.dirname(__FILE__), 'Growl.framework')
43
+ @@notifier = Notifier.new('Rum', 'Notification')
44
+ end
45
+
46
+ private
47
+
48
+ def message_backend(text, title, sticky, callback)
49
+ title ||= 'Rum' # Mac Growl needs a title
50
+ @@notifier.notify(title, text, sticky, callback)
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,207 @@
1
+ #
2
+ # irb/completor.rb -
3
+ # $Release Version: 0.9$
4
+ # $Revision: 23233 $
5
+ # by Keiju ISHITSUKA(keiju@ishitsuka.com)
6
+ # From Original Idea of shugo@ruby-lang.org
7
+ #
8
+
9
+ require "readline"
10
+
11
+ module IRB
12
+ module InputCompletor
13
+
14
+ @RCS_ID='-$Id: completion.rb 23233 2009-04-19 13:35:47Z yugui $-'
15
+
16
+ ReservedWords = [
17
+ "BEGIN", "END",
18
+ "alias", "and",
19
+ "begin", "break",
20
+ "case", "class",
21
+ "def", "defined", "do",
22
+ "else", "elsif", "end", "ensure",
23
+ "false", "for",
24
+ "if", "in",
25
+ "module",
26
+ "next", "nil", "not",
27
+ "or",
28
+ "redo", "rescue", "retry", "return",
29
+ "self", "super",
30
+ "then", "true",
31
+ "undef", "unless", "until",
32
+ "when", "while",
33
+ "yield",
34
+ ]
35
+
36
+ CompletionProc = proc { |input|
37
+ bind = IRB.conf[:MAIN_CONTEXT].workspace.binding
38
+
39
+ # puts "input: #{input}"
40
+
41
+ case input
42
+ when /^(\/[^\/]*\/)\.([^.]*)$/
43
+ # Regexp
44
+ receiver = $1
45
+ message = Regexp.quote($2)
46
+
47
+ candidates = Regexp.instance_methods.collect{|m| m.to_s}
48
+ select_message(receiver, message, candidates)
49
+
50
+ when /^([^\]]*\])\.([^.]*)$/
51
+ # Array
52
+ receiver = $1
53
+ message = Regexp.quote($2)
54
+
55
+ candidates = Array.instance_methods.collect{|m| m.to_s}
56
+ select_message(receiver, message, candidates)
57
+
58
+ when /^([^\}]*\})\.([^.]*)$/
59
+ # Proc or Hash
60
+ receiver = $1
61
+ message = Regexp.quote($2)
62
+
63
+ candidates = Proc.instance_methods.collect{|m| m.to_s}
64
+ candidates |= Hash.instance_methods.collect{|m| m.to_s}
65
+ select_message(receiver, message, candidates)
66
+
67
+ when /^(:[^:.]*)$/
68
+ # Symbol
69
+ if Symbol.respond_to?(:all_symbols)
70
+ sym = $1
71
+ candidates = Symbol.all_symbols.collect{|s| ":" + s.id2name}
72
+ candidates.grep(/^#{sym}/)
73
+ else
74
+ []
75
+ end
76
+
77
+ when /^::([A-Z][^:\.\(]*)$/
78
+ # Absolute Constant or class methods
79
+ receiver = $1
80
+ candidates = Object.constants.collect{|m| m.to_s}
81
+ candidates.grep(/^#{receiver}/).collect{|e| "::" + e}
82
+
83
+ when /^(((::)?[A-Z][^:.\(]*)+)::?([^:.]*)$/
84
+ # Constant or class methods
85
+ receiver = $1
86
+ message = Regexp.quote($4)
87
+ begin
88
+ candidates = eval("#{receiver}.constants.collect{|m| m.to_s}", bind)
89
+ candidates |= eval("#{receiver}.methods.collect{|m| m.to_s}", bind)
90
+ rescue Exception
91
+ candidates = []
92
+ end
93
+ candidates.grep(/^#{message}/).collect{|e| receiver + "::" + e}
94
+
95
+ when /^(:[^:.]+)\.([^.]*)$/
96
+ # Symbol
97
+ receiver = $1
98
+ message = Regexp.quote($2)
99
+
100
+ candidates = Symbol.instance_methods.collect{|m| m.to_s}
101
+ select_message(receiver, message, candidates)
102
+
103
+ when /^(-?(0[dbo])?[0-9_]+(\.[0-9_]+)?([eE]-?[0-9]+)?)\.([^.]*)$/
104
+ # Numeric
105
+ receiver = $1
106
+ message = Regexp.quote($5)
107
+
108
+ begin
109
+ candidates = eval(receiver, bind).methods.collect{|m| m.to_s}
110
+ rescue Exception
111
+ candidates = []
112
+ end
113
+ select_message(receiver, message, candidates)
114
+
115
+ when /^(-?0x[0-9a-fA-F_]+)\.([^.]*)$/
116
+ # Numeric(0xFFFF)
117
+ receiver = $1
118
+ message = Regexp.quote($2)
119
+
120
+ begin
121
+ candidates = eval(receiver, bind).methods.collect{|m| m.to_s}
122
+ rescue Exception
123
+ candidates = []
124
+ end
125
+ select_message(receiver, message, candidates)
126
+
127
+ when /^(\$[^.]*)$/
128
+ regmessage = Regexp.new(Regexp.quote($1))
129
+ candidates = global_variables.collect{|m| m.to_s}.grep(regmessage)
130
+
131
+ # when /^(\$?(\.?[^.]+)+)\.([^.]*)$/
132
+ when /^((\.?[^.]+)+)\.([^.]*)$/
133
+ # variable
134
+ receiver = $1
135
+ message = Regexp.quote($3)
136
+
137
+ gv = eval("global_variables", bind).collect{|m| m.to_s}
138
+ lv = eval("local_variables", bind).collect{|m| m.to_s}
139
+ cv = eval("self.class.constants", bind).collect{|m| m.to_s}
140
+
141
+ if (gv | lv | cv).include?(receiver)
142
+ # foo.func and foo is local var.
143
+ candidates = eval("#{receiver}.methods", bind).collect{|m| m.to_s}
144
+ elsif /^[A-Z]/ =~ receiver and /\./ !~ receiver
145
+ # Foo::Bar.func
146
+ begin
147
+ candidates = eval("#{receiver}.methods", bind).collect{|m| m.to_s}
148
+ rescue Exception
149
+ candidates = []
150
+ end
151
+ else
152
+ # func1.func2
153
+ candidates = []
154
+ ObjectSpace.each_object(Module){|m|
155
+ begin
156
+ name = m.name
157
+ rescue Exception
158
+ name = ""
159
+ end
160
+ next if name != "IRB::Context" and
161
+ /^(IRB|SLex|RubyLex|RubyToken)/ =~ name
162
+ candidates.concat m.instance_methods(false).collect{|x| x.to_s}
163
+ }
164
+ candidates.sort!
165
+ candidates.uniq!
166
+ end
167
+ select_message(receiver, message, candidates)
168
+
169
+ when /^\.([^.]*)$/
170
+ # unknown(maybe String)
171
+
172
+ receiver = ""
173
+ message = Regexp.quote($1)
174
+
175
+ candidates = String.instance_methods(true).collect{|m| m.to_s}
176
+ select_message(receiver, message, candidates)
177
+
178
+ else
179
+ candidates = eval("methods | private_methods | local_variables | self.class.constants", bind).collect{|m| m.to_s}
180
+
181
+ (candidates|ReservedWords).grep(/^#{Regexp.quote(input)}/)
182
+ end
183
+ }
184
+
185
+ Operators = ["%", "&", "*", "**", "+", "-", "/",
186
+ "<", "<<", "<=", "<=>", "==", "===", "=~", ">", ">=", ">>",
187
+ "[]", "[]=", "^", "!", "!=", "!~"]
188
+
189
+ def self.select_message(receiver, message, candidates)
190
+ candidates.grep(/^#{message}/).collect do |e|
191
+ case e
192
+ when /^[a-zA-Z_]/
193
+ receiver + "." + e
194
+ when /^[0-9]/
195
+ when *Operators
196
+ #receiver + " " + e
197
+ end
198
+ end
199
+ end
200
+ end
201
+ end
202
+
203
+ if Readline.respond_to?("basic_word_break_characters=")
204
+ Readline.basic_word_break_characters= " \t\n\"\\'`><=;|&{("
205
+ end
206
+ Readline.completion_append_character = nil
207
+ Readline.completion_proc = IRB::InputCompletor::CompletionProc
@@ -0,0 +1,73 @@
1
+ framework "ApplicationServices"
2
+ framework "#{File.dirname(__FILE__)}/keyboard_hook/KeyboardHook.framework"
3
+ framework 'Cocoa'
4
+
5
+ module KeyboardHook
6
+ def self.start &block
7
+ @tap = EventTap.new
8
+ @tap.on_event &block
9
+ NSApplication.sharedApplication.run()
10
+ end
11
+
12
+ def self.stop
13
+ # Todo: cleanup, unregister hook
14
+ NSApplication.sharedApplication.terminate(nil)
15
+ end
16
+ end
17
+
18
+ class EventTap
19
+ def handleEvent(event)
20
+ event if @proc.call(event)
21
+ end
22
+
23
+ def on_event(&proc)
24
+ @proc = proc
25
+ end
26
+ end
27
+
28
+ class Event
29
+ def set_event_source(source)
30
+ CGEventSetSource(eventRef, source)
31
+ end
32
+
33
+ def set_keycode(code)
34
+ set_integer_value_field(KCGKeyboardEventKeycode, code)
35
+ end
36
+
37
+ def down?
38
+ down != 0
39
+ end
40
+
41
+ def keycode
42
+ get_integer_value_field(KCGKeyboardEventKeycode)
43
+ end
44
+
45
+ def id
46
+ get_integer_value_field(KCGKeyboardEventKeycode)
47
+ end
48
+
49
+ def to_s
50
+ "#{down? ? 'Down' : 'Up'}: Id #{id}"
51
+ end
52
+
53
+ def set_integer_value_field(field, value)
54
+ CGEventSetIntegerValueField(eventRef, field, value)
55
+ end
56
+
57
+ def get_integer_value_field(field)
58
+ CGEventGetIntegerValueField(eventRef, field)
59
+ end
60
+
61
+ def get_user_data
62
+ CGEventGetIntegerValueField(eventRef, KCGEventSourceUnixProcessID)
63
+ end
64
+
65
+ def get_flags
66
+ CGEventGetFlags(eventRef)
67
+ end
68
+
69
+ def set_flags(flags)
70
+ CGEventSetFlags(eventRef, flags)
71
+ end
72
+ end
73
+
@@ -0,0 +1,146 @@
1
+ # encoding: utf-8
2
+
3
+ module Rum
4
+ module Layouts
5
+ module_function
6
+
7
+ def default_layout
8
+ us
9
+ end
10
+
11
+ # /System/Library/Frameworks/Carbon.framework/.../Events.h
12
+ def core
13
+ core = Layout.new
14
+
15
+ [['return', "\n", 36],
16
+ ['tab', 48],
17
+ ['space', ' ', 49],
18
+ ['delete', 51],
19
+ ['escape', 53],
20
+ ['rightcommand', 54],
21
+ ['command', 55],
22
+ ['shift', 56],
23
+ ['capslock', 57],
24
+ ['option', 58],
25
+ ['control', 59],
26
+ ['rightshift', 60],
27
+ ['rightoption', 61],
28
+ ['rightcontrol', 62],
29
+ ['function', 63],
30
+ ['f17', 64],
31
+ ['volumeup', 72],
32
+ ['volumedown', 73],
33
+ ['mute', 74],
34
+ ['f18', 79],
35
+ ['f19', 80],
36
+ ['f20', 90],
37
+ ['f5', 96],
38
+ ['f6', 97],
39
+ ['f7', 98],
40
+ ['f3', 99],
41
+ ['f8', 100],
42
+ ['f9', 101],
43
+ ['f11', 103],
44
+ ['f13', 105],
45
+ ['f16', 106],
46
+ ['f14', 107],
47
+ ['f10', 109],
48
+ ['f12', 111],
49
+ ['f15', 113],
50
+ ['help', 114],
51
+ ['home', 115],
52
+ ['pageup', 116],
53
+ ['forward_delete', 117],
54
+ ['f4', 118],
55
+ ['end', 119],
56
+ ['f2', 120],
57
+ ['pagedown', 121],
58
+ ['f1', 122],
59
+ ['leftarrow', 123],
60
+ ['rightarrow', 124],
61
+ ['downarrow', 125],
62
+ ['uparrow', 126]].each { |key| core.add *key }
63
+
64
+ core
65
+ end
66
+
67
+ def basic
68
+ basic = core
69
+
70
+ [['decimal', 65],
71
+ ['multiply', 67],
72
+ ['add', 69],
73
+ ['numlock', 71],
74
+ ['divide', 75],
75
+ ['numpadenter', 76],
76
+ ['subtract', 78],
77
+ ['numpad0', 82],
78
+ ['numpad1', 83],
79
+ ['numpad2', 84],
80
+ ['numpad3', 85],
81
+ ['numpad4', 86],
82
+ ['numpad5', 87],
83
+ ['numpad6', 88],
84
+ ['numpad7', 89],
85
+ ['numpad8', 91],
86
+ ['numpad9', 92],
87
+ ['apps', 110]].each { |key| basic.add *key }
88
+
89
+ basic.remap 'rightshift', 'shift'
90
+ basic.remap 'rightcontrol', 'control'
91
+ basic.remap 'rightoption', 'option'
92
+ basic.remap 'rightcommand', 'command'
93
+
94
+ basic.rename 'uparrow', 'up'
95
+ basic.rename 'rightarrow', 'right'
96
+ basic.rename 'downarrow', 'down'
97
+ basic.rename 'leftarrow', 'left'
98
+ basic.rename 'help', 'insert'
99
+ basic.alias 'insert', 'help'
100
+ basic.rename 'delete', 'backspace'
101
+ basic.rename 'forward_delete', 'delete'
102
+ basic.rename 'return', 'enter'
103
+ basic.alias 'enter', 'return'
104
+ basic.rename 'capslock', 'caps'
105
+
106
+ basic.alias 'f13', 'print'
107
+ basic.alias 'f14', 'scroll'
108
+ basic.alias 'f15', 'pause'
109
+
110
+ basic.alias 'command', 'cmd'
111
+ basic.alias 'function', 'fn'
112
+
113
+ %w{command control option shift function}.each do |key|
114
+ basic.core_modifier key
115
+ end
116
+
117
+ basic
118
+ end
119
+
120
+ def us
121
+ us = basic
122
+ %w{a s d f h g z x c v § b q w e r y t 1 2 3 4 6
123
+ 5 = 9 7 - 8 0 ] o u [ i p _ l j _ k ; _ , / n m .}.each_with_index do |key, id|
124
+ us.add key, id unless key == '_'
125
+ end
126
+
127
+ us.add "'", 39
128
+ us.add '\\', 42
129
+ us.add '`', 50
130
+
131
+ us
132
+ end
133
+
134
+ def german
135
+ german = basic
136
+ %w{a s d f h g z x c v ^ b q w e r y t 1 2 3 4 6
137
+ 5 ´ 9 7 ß 8 0 + o u ü i p _ l j ä k ö # , - n m .}.each_with_index do |key, id|
138
+ german.add key, id unless key == '_'
139
+ end
140
+
141
+ german.add '<', 50
142
+
143
+ german
144
+ end
145
+ end
146
+ end