te2ak 0.0.1
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/Gemfile +4 -0
- data/README.markdown +26 -0
- data/Rakefile +2 -0
- data/bin/te2ak +11 -0
- data/lib/te2ak.rb +2 -0
- data/lib/te2ak/te2ak.rb +144 -0
- data/lib/te2ak/version.rb +3 -0
- data/te2ak.gemspec +24 -0
- metadata +118 -0
data/Gemfile
ADDED
data/README.markdown
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# About
|
2
|
+
|
3
|
+
te2ak is a simple utility that helps converting Textexpander settings to Autokey
|
4
|
+
scripts under linux, where Textexpander is not available.
|
5
|
+
This way the same settings can be used on Mac OSX (TE), Windows (Breevy) and
|
6
|
+
Linux (AutoKey)
|
7
|
+
|
8
|
+
# Usage
|
9
|
+
|
10
|
+
te2ak Settings.textexpander autokey.json
|
11
|
+
|
12
|
+
# License
|
13
|
+
|
14
|
+
Copyright c 2010, Zoltan Dezso <dezso.zoltan@gmail.com>
|
15
|
+
|
16
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in
|
17
|
+
the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
18
|
+
Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
19
|
+
|
20
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
21
|
+
|
22
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
23
|
+
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
|
24
|
+
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
25
|
+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
26
|
+
|
data/Rakefile
ADDED
data/bin/te2ak
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
3
|
+
require 'te2ak/te2ak'
|
4
|
+
if ARGV.length != 2
|
5
|
+
puts <<-EOF
|
6
|
+
Usage: te2ak <Textexpander Settings File> <Autokey Json file to output>
|
7
|
+
Example: te2ak ~/Dropbox/Textexpander/Settings.textexpander ~/.config/autokey/autokey.json
|
8
|
+
EOF
|
9
|
+
else
|
10
|
+
TE2AK::Te2Ak.new.run(ARGV[0], ARGV[1])
|
11
|
+
end
|
data/lib/te2ak.rb
ADDED
data/lib/te2ak/te2ak.rb
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require 'rubygems'
|
3
|
+
require 'plist'
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
## Usage:
|
7
|
+
## te2ak Settings.textexpander autokey.json
|
8
|
+
|
9
|
+
module TE2AK
|
10
|
+
class Te2Ak
|
11
|
+
POSITIONS_REGEX = /(?<!%)%\|/
|
12
|
+
CLIPBOARD_REGEX = /(?<!%)%\(?clipboard\)?/
|
13
|
+
SPECIALCH_REGEX = /(?<!%)%(?:[|<>]|\(?clipboard\)?)/
|
14
|
+
|
15
|
+
def initialize
|
16
|
+
@result = {
|
17
|
+
'folders'=>[
|
18
|
+
{
|
19
|
+
'folders' => [],
|
20
|
+
'usageCount' => 0,
|
21
|
+
'modes' => [],
|
22
|
+
'abbreviation' => {
|
23
|
+
'ignoreCase' => false,
|
24
|
+
'wordChars' => '[\\w]',
|
25
|
+
'immediate' => false,
|
26
|
+
'abbreviation' => nil,
|
27
|
+
'backspace' => true,
|
28
|
+
'triggerInside' => false
|
29
|
+
},
|
30
|
+
'title' => 'All',
|
31
|
+
'hotkey' => {
|
32
|
+
'hotKey' => nil,
|
33
|
+
'modifiers' => []
|
34
|
+
},
|
35
|
+
'items' => [],
|
36
|
+
'filter' => nil,
|
37
|
+
'type' => 'folder',
|
38
|
+
'showInTrayMenu' => false
|
39
|
+
}
|
40
|
+
],
|
41
|
+
'toggleServiceHotkey' => {
|
42
|
+
'hotKey' => 'k',
|
43
|
+
'modifiers' => ['<shift>', '<super>'],
|
44
|
+
'enabled' => true
|
45
|
+
},
|
46
|
+
'settings' => {
|
47
|
+
'showTrayIcon' => true,
|
48
|
+
'windowDefaultSize' => [600,400],
|
49
|
+
'undoUsingBackspace' => true,
|
50
|
+
'enableQT4Workaround' => false,
|
51
|
+
'promptToSave' => true,
|
52
|
+
'interfaceType' => 'XRecord',
|
53
|
+
'showToolbar' => true,
|
54
|
+
'serviceRunning' => true,
|
55
|
+
'columnWidths' => [150,50,100],
|
56
|
+
'isFirstRun' => false,
|
57
|
+
'sortByUsageCount' => true,
|
58
|
+
'notificationIcon' => '/usr/share/pixmaps/akicon.png',
|
59
|
+
'hPanePosition' => 150,
|
60
|
+
'menuTakesFocus'=> false
|
61
|
+
},
|
62
|
+
'userCodeDir' => nil,
|
63
|
+
"version" => "0.71.0",
|
64
|
+
"showPopupHotkey" => {
|
65
|
+
"hotKey" => nil,
|
66
|
+
"modifiers" => [],
|
67
|
+
"enabled" => false
|
68
|
+
},
|
69
|
+
"configHotkey" => {
|
70
|
+
"hotKey" => "k",
|
71
|
+
"modifiers" => ["<super>"],
|
72
|
+
"enabled" => true
|
73
|
+
}
|
74
|
+
}
|
75
|
+
end
|
76
|
+
|
77
|
+
def codify(str)
|
78
|
+
# TODO: %< %>
|
79
|
+
|
80
|
+
jumpback = 0
|
81
|
+
if str =~ POSITIONS_REGEX
|
82
|
+
# assume only one place
|
83
|
+
# calculate position based on cleared string
|
84
|
+
str2 = str.gsub(CLIPBOARD_REGEX, '').gsub(/%%/, '')
|
85
|
+
jumpback = str2.length - 2 - str2.rindex(POSITIONS_REGEX)
|
86
|
+
str.gsub!(POSITIONS_REGEX, '')
|
87
|
+
end
|
88
|
+
str = 'keyboard.send_keys("' + str.gsub(/(?<!\\)"/, '\"').gsub(/\n/, '<enter>').gsub(CLIPBOARD_REGEX, %!");\nkeyboard.send_keys(clipboard.get_clipboard());\nkeyboard.send_keys("!) + '");'
|
89
|
+
if jumpback != 0
|
90
|
+
str += %!\nkeyboard.send_keys("#{'<left>'*jumpback}");!
|
91
|
+
end
|
92
|
+
str.gsub(/%%/, '%')
|
93
|
+
end
|
94
|
+
|
95
|
+
def run(input, output)
|
96
|
+
if File.exist?(input)
|
97
|
+
te = Plist::parse_xml File.open(input).read
|
98
|
+
ahk = te['snippetsTE2']
|
99
|
+
|
100
|
+
ahk.each do |a|
|
101
|
+
script = false
|
102
|
+
if (a['plainText'] =~ SPECIALCH_REGEX)
|
103
|
+
code = codify(a['plainText'])
|
104
|
+
script = true
|
105
|
+
end
|
106
|
+
abbreviation = {
|
107
|
+
'usageCount' => 0,
|
108
|
+
'omitTrigger' => false,
|
109
|
+
'prompt' => false,
|
110
|
+
'description' => a['label'],
|
111
|
+
'abbreviation' => {
|
112
|
+
'ignoreCase' => false,
|
113
|
+
'wordChars' => "[^ \\n]",
|
114
|
+
'immediate' => true,
|
115
|
+
'abbreviation' => a['abbreviation'].gsub(/%%/, '%'),
|
116
|
+
'backspace' => true,
|
117
|
+
'triggerInside'=> false
|
118
|
+
},
|
119
|
+
'hotkey' => {
|
120
|
+
'hotKey' => nil,
|
121
|
+
'modifiers' => []
|
122
|
+
},
|
123
|
+
'modes' => [1],
|
124
|
+
"showInTrayMenu" => false,
|
125
|
+
'matchCase' => false,
|
126
|
+
'filter' => nil,
|
127
|
+
'sendMode' => 'kb'
|
128
|
+
}
|
129
|
+
if script
|
130
|
+
abbreviation['code'] = code
|
131
|
+
abbreviation['type'] = 'script'
|
132
|
+
abbreviation['store'] = {}
|
133
|
+
else
|
134
|
+
abbreviation['phrase'] = a['plainText'].gsub(/%%/, '%')
|
135
|
+
abbreviation['type'] = 'phrase'
|
136
|
+
end
|
137
|
+
@result['folders'][0]['items'] << abbreviation
|
138
|
+
end
|
139
|
+
|
140
|
+
File.open(output, 'w') {|f| f.write(@result.to_json) }
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
data/te2ak.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path("../lib/te2ak/version", __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "te2ak"
|
6
|
+
s.version = TE2AK::VERSION
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.authors = ['Zoltan Dezso']
|
9
|
+
s.email = ['dezso.zoltan@gmail.com']
|
10
|
+
s.homepage = "http://github.com/zaki/te2ak"
|
11
|
+
s.summary = "A simple utility to convert Textexpander snippets to AutoKey scripts."
|
12
|
+
s.description = "A simple utility to convert Textexpander snippets to AutoKey scripts."
|
13
|
+
|
14
|
+
s.required_rubygems_version = ">= 1.3.6"
|
15
|
+
s.rubyforge_project = "te2ak"
|
16
|
+
|
17
|
+
s.add_development_dependency "bundler", ">= 1.0.0"
|
18
|
+
s.add_dependency "plist", ">= 3.1.0"
|
19
|
+
s.add_dependency "json", ">= 1.4.6"
|
20
|
+
|
21
|
+
s.files = `git ls-files`.split("\n")
|
22
|
+
s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
|
23
|
+
s.require_path = 'lib'
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: te2ak
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Zoltan Dezso
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-11-26 00:00:00 +09:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: bundler
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 1
|
30
|
+
- 0
|
31
|
+
- 0
|
32
|
+
version: 1.0.0
|
33
|
+
type: :development
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: plist
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
segments:
|
44
|
+
- 3
|
45
|
+
- 1
|
46
|
+
- 0
|
47
|
+
version: 3.1.0
|
48
|
+
type: :runtime
|
49
|
+
version_requirements: *id002
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
name: json
|
52
|
+
prerelease: false
|
53
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
segments:
|
59
|
+
- 1
|
60
|
+
- 4
|
61
|
+
- 6
|
62
|
+
version: 1.4.6
|
63
|
+
type: :runtime
|
64
|
+
version_requirements: *id003
|
65
|
+
description: A simple utility to convert Textexpander snippets to AutoKey scripts.
|
66
|
+
email:
|
67
|
+
- dezso.zoltan@gmail.com
|
68
|
+
executables:
|
69
|
+
- te2ak
|
70
|
+
extensions: []
|
71
|
+
|
72
|
+
extra_rdoc_files: []
|
73
|
+
|
74
|
+
files:
|
75
|
+
- Gemfile
|
76
|
+
- README.markdown
|
77
|
+
- Rakefile
|
78
|
+
- bin/te2ak
|
79
|
+
- lib/te2ak.rb
|
80
|
+
- lib/te2ak/te2ak.rb
|
81
|
+
- lib/te2ak/version.rb
|
82
|
+
- te2ak.gemspec
|
83
|
+
has_rdoc: true
|
84
|
+
homepage: http://github.com/zaki/te2ak
|
85
|
+
licenses: []
|
86
|
+
|
87
|
+
post_install_message:
|
88
|
+
rdoc_options: []
|
89
|
+
|
90
|
+
require_paths:
|
91
|
+
- lib
|
92
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
none: false
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
segments:
|
98
|
+
- 0
|
99
|
+
version: "0"
|
100
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
|
+
none: false
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
segments:
|
106
|
+
- 1
|
107
|
+
- 3
|
108
|
+
- 6
|
109
|
+
version: 1.3.6
|
110
|
+
requirements: []
|
111
|
+
|
112
|
+
rubyforge_project: te2ak
|
113
|
+
rubygems_version: 1.3.7
|
114
|
+
signing_key:
|
115
|
+
specification_version: 3
|
116
|
+
summary: A simple utility to convert Textexpander snippets to AutoKey scripts.
|
117
|
+
test_files: []
|
118
|
+
|