my_help 0.3.2 → 0.3.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0a89c867608e778797c4e8e58f2374c991f76ebd
4
- data.tar.gz: caf2008be34a3aeff33a269d204c75c423cdbfe2
3
+ metadata.gz: 7a1841fa8a0cf72b7a2d735f891a572549b67688
4
+ data.tar.gz: 84879c6e36ddae1fb746450dd853c8e4ef32382e
5
5
  SHA512:
6
- metadata.gz: 11c14fd942b45faf9b2f662278ea9a0fe32b9f33d14ebffc14557ecf53b2c5045ce8ad200ebf64dcb50e859c8209db7649bf7d06b1b2e413c6c59e168e580834
7
- data.tar.gz: ab28ef71626b921cbb914ddc62c7d03530caf4bd783672d220c7bb530c2574bb5a93aa22a23a365640834ce077b06b2e58eda952c480039af8dcd29e9df83910
6
+ metadata.gz: 5b4dd58e5410ec0a52c23b4e662c5adc301c3475d7db9426bc25095c985ecfb26b24f65cbbb6023b3e6760f994aaa56260974838cb81c56800baf0da6334b318
7
+ data.tar.gz: 2cc1c5daa8a351f69f454c774fd8b428236c81bf30b14661d45cddb86c545ce7c501ee0ed33ef9562a745ed1b5cb4d854e6a51a6155fd0c7203c2f703f14f1fc
data/README.md CHANGED
@@ -30,6 +30,11 @@ commandや文法を覚えるのに苦労します.少しのkey(とっかかり
30
30
  hikiでやろうとしていることの半分くらいはこのあたりのことなの
31
31
  かもしれません.memoソフトでは,検索が必要となりますが,my_helpは
32
32
  key(記憶のとっかかり)を提供することが目的です.
33
+ RPGでレベル上げとかアイテムを貯めるようにして,
34
+ プログラミングでスキルを発展させてください.
35
+
36
+ 物覚えの悪い作者は,人の名前をitem分けして,こそっと使っています.
37
+
33
38
 
34
39
  # 使用法
35
40
  ## インストール
@@ -56,6 +61,7 @@ Usage: my_help [options]
56
61
  -m, --make make executables for all helps.
57
62
  -c, --clean clean up exe dir.
58
63
  --install_local install local after edit helps
64
+ --delete NAME delete NAME help
59
65
  ```
60
66
  です.まず,-lでdefaultで入っているリストを見てください.
61
67
 
@@ -65,9 +71,35 @@ bob% bundle exec exe/my_help -l
65
71
  ["-l"]
66
72
  Specific help file:
67
73
  emacs_help
68
- test_help
69
74
  ```
70
- これで,CUIでemacs_help, e_h, template_help, t_hが用意されています.少し振る舞いに慣れてください.
75
+ これで,CUIでemacs_help, e_hが用意されています.
76
+
77
+ ```
78
+ emacsのキーバインド
79
+
80
+ 特殊キー操作
81
+ c-f, controlキーを押しながら 'f'
82
+ M-f, escキーを押した後一度離して'f'
83
+ 操作の中断c-g, 操作の取り消し(Undo) c-x u
84
+ cc by Shigeto R. Nishitani, 2016
85
+ Usage: e_h [options]
86
+ -v, --version show program Version.
87
+ -c, --cursor Cursor移動
88
+ -e, --編集 Edit操作
89
+ -f, --ファイル File操作
90
+ -q, --終了 終了操作
91
+ -p, --ページ Page移動
92
+ -w, --ウィンドウ Window操作
93
+ -b, --バッファ Buffer操作
94
+ -m, --mode モード切り替え
95
+ --edit edit help contents
96
+ --to_hiki convert to hikidoc format
97
+ --all display all helps
98
+ --store [item] store [item] in back
99
+ --remove [item] remove [item] in back
100
+ --add [item] add new [item]
101
+ ```
102
+ 少し振る舞いに慣れてください.
71
103
 
72
104
  ## 独自のhelpを作る方法
73
105
  さて,独自のhelpを作る方法です.まずは,
@@ -78,7 +110,12 @@ bob% bundle exec exe/my_help -i new_help
78
110
  "/Users/bob/Github/my_help/lib/daddygongon/template_help"
79
111
  cp /Users/bob/Github/my_help/lib/daddygongon/template_help /Users/bob/.my_help/new_help
80
112
  ```
81
- で,new_helpというtemplateが用意されます.-e new_helpで編集してください.そのあと,-mすると自動でnew_helpがexeディレクトリーに追加されます.
113
+ で,new_helpというtemplateが用意されます.-e new_helpで編集してください.
114
+ YAML形式で,格納されています.サンプルが,
115
+ ```
116
+ my_help/lib/daddygongon
117
+ ```
118
+ にあります.このあと,-mすると自動でnew_helpがexeディレクトリーに追加されます.
82
119
 
83
120
  ## 独自helpを使えるように
84
121
  (これは,-mで自動的に行われるように修正されています)
@@ -98,8 +135,8 @@ cp /Users/bob/Github/my_help/lib/daddygongon/template_help /Users/bob/.my_help/n
98
135
  - @target dirをmy_help/lib/daddygongonからENV['HOME']/.my_helpに変更
99
136
 
100
137
  exe中のファイルをrakeで自動生成.
101
- @target_dirにそれらのdataを保存.以下ではその名前から
102
- exe中に実行ファイルを自動生成させている.
138
+ @target_dirにそれらのdataを保存.
139
+ その名前からexe中に実行ファイルを自動生成させている.
103
140
  ```
104
141
  lib/daddygongon/
105
142
  └── emacs_help
@@ -123,34 +160,32 @@ rake install:local
123
160
  gem uninstall my_help
124
161
  gem uninstall emacs_help
125
162
  ```
126
- でそのdirをcleanにしておくことが望ましい.
163
+ でそのdirをcleanにしておくことが望ましい.下のuninstallの項目を参照.
127
164
 
128
- 中身は以下の通り.
165
+ -mでやっている中身は以下の通り.
129
166
  ```ruby
130
- desc "make own help from lib/daddygongon/files"
131
- task :my_help do
132
- exe_cont="#!/usr/bin/env ruby\n"
133
- user_name = 'daddygongon'
134
- p entries=Dir.entries(File.join('.','lib',user_name))[2..-1]
135
- entries.each{|file|
136
- p file
137
- p file_name=file.split('_')
138
- target_files = [file, file_name[0][0]+"_"+file_name[1][0]]
139
- p cont_name = File.join('lib',user_name,file)
140
- exe_cont << "require 'my_help'\n"
141
- exe_cont << "help_file = File.expand_path(\"../../#{cont_name}\", __FILE__)\n"
142
- exe_cont << "MyHelp::Command.run(help_file, ARGV)\n"
143
- target_files.each{|name|
144
- p ''
145
- p target=File.join('exe',name)
146
- File.open(target,'w'){|file|
147
- print exe_cont
148
- file.print exe_cont
167
+ def make_help
168
+ Dir.entries(@target_dir)[2..-1].each{|file|
169
+ next if file[0]=='#' or file[-1]=='~'
170
+ exe_cont="#!/usr/bin/env ruby\nrequire 'specific_help'\n"
171
+ exe_cont << "help_file = File.join(ENV['HOME'],'.my_help','#{file}')\n"
172
+ exe_cont << "SpecificHelp::Command.run(help_file, ARGV)\n"
173
+ [file, short_name(file)].each{|name|
174
+ p target=File.join('exe',name)
175
+ File.open(target,'w'){|file| file.print exe_cont}
176
+ FileUtils.chmod('a+x', target, :verbose => true)
177
+ }
149
178
  }
150
- FileUtils.chmod('a+x', target, :verbose => true)
151
- }
152
- }
153
- end
179
+ install_local
180
+ end
181
+
182
+ def install_local
183
+ #中略
184
+ system "git add -A"
185
+ system "git commit -m 'update exe dirs'"
186
+ system "Rake install:local"
187
+ end
188
+
154
189
  ```
155
190
 
156
191
  実装方法は,emacs_helpに
@@ -162,10 +197,30 @@ end
162
197
  今の所,No.1の方を実装.No.2のためのhushデータは,
163
198
 
164
199
  ```ruby
200
+ # -*- coding: utf-8 -*-
165
201
  require 'yaml'
166
202
  require 'pp'
167
-
168
- pp YAML.load(File.read(ARGV[0]))
203
+ yaml =<<EOF
204
+ :file:
205
+ :opts:
206
+ :short: "-f"
207
+ :cont:
208
+ - c-x c-f, Find file, ファイルを開く
209
+ - c-x c-s, Save file, ファイルを保存
210
+ EOF
211
+ pp data=YAML.load(yaml)
212
+ print YAML.dump(data)
213
+
214
+
215
+ data0={:file=>
216
+ {:opts=>{:short=>"-f", :long=>"--ファイル", :desc=>"File操作"},
217
+ :title=>"ファイル操作file",
218
+ :cont=>
219
+ ["c-x c-f, Find file, ファイルを開く
220
+ c-x c-s, Save file, ファイルを保存
221
+ c-x c-w, Write file NAME, ファイルを別名で書き込む"]}}
222
+
223
+ print YAML.dump(data0)
169
224
  ```
170
225
 
171
226
  ```
data/README_en.md CHANGED
@@ -53,12 +53,13 @@ Supplied commands are
53
53
  bob% bundle exec exe/my_help
54
54
  Usage: my_help [options]
55
55
  -v, --version show program Version.
56
- -l, --list list specific help.
57
- -e, --edit NAME edit NAME(cf test_help).
58
- -i, --init NAME initialize NAME(cf, test_help) template.
59
- -m, --make make and install:local all helps.
56
+ -l, --list list specific helps
57
+ -e, --edit NAME edit NAME help(eg test_help)
58
+ -i, --init NAME initialize NAME help(eg test_help).
59
+ -m, --make make executables for all helps.
60
60
  -c, --clean clean up exe dir.
61
61
  --install_local install local after edit helps
62
+ --delete NAME delete NAME help
62
63
  ```
63
64
 
64
65
  At first, see the list of supplied helps by the option of -l.
@@ -74,6 +75,32 @@ Specific help file:
74
75
  emacs_help, e_h, test_help, t_h are ready to use.
75
76
  Play them by a command such as 'bundle exec exe/e_h'.
76
77
 
78
+ emacsのキーバインド
79
+
80
+ ```
81
+ 特殊キー操作
82
+ c-f, controlキーを押しながら 'f'
83
+ M-f, escキーを押した後一度離して'f'
84
+ 操作の中断c-g, 操作の取り消し(Undo) c-x u
85
+ cc by Shigeto R. Nishitani, 2016
86
+ Usage: e_h [options]
87
+ -v, --version show program Version.
88
+ -c, --cursor Cursor移動
89
+ -e, --編集 Edit操作
90
+ -f, --ファイル File操作
91
+ -q, --終了 終了操作
92
+ -p, --ページ Page移動
93
+ -w, --ウィンドウ Window操作
94
+ -b, --バッファ Buffer操作
95
+ -m, --mode モード切り替え
96
+ --edit edit help contents
97
+ --to_hiki convert to hikidoc format
98
+ --all display all helps
99
+ --store [item] store [item] in back
100
+ --remove [item] remove [item] in back
101
+ --add [item] add new [item]
102
+ ```
103
+
77
104
  ## Make own help
78
105
  The next step is making own help.
79
106
  For this, -i NAME supplies new NAME help.
data/Rakefile CHANGED
@@ -14,6 +14,16 @@ task :yard => [:hiki2md] do
14
14
  YARD::Rake::YardocTask.new
15
15
  end
16
16
 
17
+ desc "clean up exe dir"
18
+ task :clean_exe do
19
+ files = Dir.entries('exe')
20
+ files.each{|file|
21
+ next if ["my_help",".","..",".DS_Store",
22
+ "emacs_help","e_h","template_help","t_h"].include?(file)
23
+ FileUtils.rm(File.join('./exe',file), :verbose=>true)
24
+ }
25
+ end
26
+
17
27
  desc "transfer hikis/*.hiki to wiki"
18
28
  task :hiki2md do
19
29
  files = Dir.entries('hikis')
data/exe/e_h ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require 'specific_help'
3
+ help_file = File.join(ENV['HOME'],'.my_help','emacs_help')
4
+ SpecificHelp::Command.run(help_file, ARGV)
data/exe/t_h ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require 'specific_help'
3
+ help_file = File.join(ENV['HOME'],'.my_help','template_help')
4
+ SpecificHelp::Command.run(help_file, ARGV)
data/exe/template_help ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require 'specific_help'
3
+ help_file = File.join(ENV['HOME'],'.my_help','template_help')
4
+ SpecificHelp::Command.run(help_file, ARGV)
data/hikis/README_en.hiki CHANGED
@@ -51,12 +51,13 @@ Supplied commands are
51
51
  bob% bundle exec exe/my_help
52
52
  Usage: my_help [options]
53
53
  -v, --version show program Version.
54
- -l, --list list specific help.
55
- -e, --edit NAME edit NAME(cf test_help).
56
- -i, --init NAME initialize NAME(cf, test_help) template.
57
- -m, --make make and install:local all helps.
54
+ -l, --list list specific helps
55
+ -e, --edit NAME edit NAME help(eg test_help)
56
+ -i, --init NAME initialize NAME help(eg test_help).
57
+ -m, --make make executables for all helps.
58
58
  -c, --clean clean up exe dir.
59
59
  --install_local install local after edit helps
60
+ --delete NAME delete NAME help
60
61
  >>>
61
62
 
62
63
  At first, see the list of supplied helps by the option of -l.
@@ -72,6 +73,32 @@ Specific help file:
72
73
  emacs_help, e_h, test_help, t_h are ready to use.
73
74
  Play them by a command such as 'bundle exec exe/e_h'.
74
75
 
76
+ emacsのキーバインド
77
+
78
+ <<<
79
+ 特殊キー操作
80
+ c-f, controlキーを押しながら 'f'
81
+ M-f, escキーを押した後一度離して'f'
82
+ 操作の中断c-g, 操作の取り消し(Undo) c-x u
83
+ cc by Shigeto R. Nishitani, 2016
84
+ Usage: e_h [options]
85
+ -v, --version show program Version.
86
+ -c, --cursor Cursor移動
87
+ -e, --編集 Edit操作
88
+ -f, --ファイル File操作
89
+ -q, --終了 終了操作
90
+ -p, --ページ Page移動
91
+ -w, --ウィンドウ Window操作
92
+ -b, --バッファ Buffer操作
93
+ -m, --mode モード切り替え
94
+ --edit edit help contents
95
+ --to_hiki convert to hikidoc format
96
+ --all display all helps
97
+ --store [item] store [item] in back
98
+ --remove [item] remove [item] in back
99
+ --add [item] add new [item]
100
+ >>>
101
+
75
102
  !!Make own help
76
103
  The next step is making own help.
77
104
  For this, -i NAME supplies new NAME help.
data/hikis/README_ja.hiki CHANGED
@@ -30,6 +30,11 @@ commandや文法を覚えるのに苦労します.少しのkey(とっかかり
30
30
  hikiでやろうとしていることの半分くらいはこのあたりのことなの
31
31
  かもしれません.memoソフトでは,検索が必要となりますが,my_helpは
32
32
  key(記憶のとっかかり)を提供することが目的です.
33
+ RPGでレベル上げとかアイテムを貯めるようにして,
34
+ プログラミングでスキルを発展させてください.
35
+
36
+ 物覚えの悪い作者は,人の名前をitem分けして,こそっと使っています.
37
+
33
38
 
34
39
  !使用法
35
40
  !!インストール
@@ -54,6 +59,7 @@ Usage: my_help [options]
54
59
  -m, --make make executables for all helps.
55
60
  -c, --clean clean up exe dir.
56
61
  --install_local install local after edit helps
62
+ --delete NAME delete NAME help
57
63
  >>>
58
64
  です.まず,-lでdefaultで入っているリストを見てください.
59
65
 
@@ -63,9 +69,35 @@ bob% bundle exec exe/my_help -l
63
69
  ["-l"]
64
70
  Specific help file:
65
71
  emacs_help
66
- test_help
67
72
  >>>
68
- これで,CUIでemacs_help, e_h, template_help, t_hが用意されています.少し振る舞いに慣れてください.
73
+ これで,CUIでemacs_help, e_hが用意されています.
74
+
75
+ <<<
76
+ emacsのキーバインド
77
+
78
+ 特殊キー操作
79
+ c-f, controlキーを押しながら 'f'
80
+ M-f, escキーを押した後一度離して'f'
81
+ 操作の中断c-g, 操作の取り消し(Undo) c-x u
82
+ cc by Shigeto R. Nishitani, 2016
83
+ Usage: e_h [options]
84
+ -v, --version show program Version.
85
+ -c, --cursor Cursor移動
86
+ -e, --編集 Edit操作
87
+ -f, --ファイル File操作
88
+ -q, --終了 終了操作
89
+ -p, --ページ Page移動
90
+ -w, --ウィンドウ Window操作
91
+ -b, --バッファ Buffer操作
92
+ -m, --mode モード切り替え
93
+ --edit edit help contents
94
+ --to_hiki convert to hikidoc format
95
+ --all display all helps
96
+ --store [item] store [item] in back
97
+ --remove [item] remove [item] in back
98
+ --add [item] add new [item]
99
+ >>>
100
+ 少し振る舞いに慣れてください.
69
101
 
70
102
  !!独自のhelpを作る方法
71
103
  さて,独自のhelpを作る方法です.まずは,
@@ -76,7 +108,10 @@ bob% bundle exec exe/my_help -i new_help
76
108
  "/Users/bob/Github/my_help/lib/daddygongon/template_help"
77
109
  cp /Users/bob/Github/my_help/lib/daddygongon/template_help /Users/bob/.my_help/new_help
78
110
  >>>
79
- で,new_helpというtemplateが用意されます.-e new_helpで編集してください.そのあと,-mすると自動でnew_helpがexeディレクトリーに追加されます.
111
+ で,new_helpというtemplateが用意されます.-e new_helpで編集してください.
112
+ YAML形式で,格納されています.サンプルが,
113
+ my_help/lib/daddygongon
114
+ にあります.このあと,-mすると自動でnew_helpがexeディレクトリーに追加されます.
80
115
 
81
116
  !!独自helpを使えるように
82
117
  (これは,-mで自動的に行われるように修正されています)
@@ -96,8 +131,8 @@ cp /Users/bob/Github/my_help/lib/daddygongon/template_help /Users/bob/.my_help/n
96
131
  * @target dirをmy_help/lib/daddygongonからENV['HOME']/.my_helpに変更
97
132
 
98
133
  exe中のファイルをrakeで自動生成.
99
- @target_dirにそれらのdataを保存.以下ではその名前から
100
- exe中に実行ファイルを自動生成させている.
134
+ @target_dirにそれらのdataを保存.
135
+ その名前からexe中に実行ファイルを自動生成させている.
101
136
  <<<
102
137
  lib/daddygongon/
103
138
  └── emacs_help
@@ -115,34 +150,32 @@ exe
115
150
  たくさんの実行ファイルを/usr/loca/binに置くことになるので,あらたなmy_helpを作成するときには
116
151
  gem uninstall my_help
117
152
  gem uninstall emacs_help
118
- でそのdirをcleanにしておくことが望ましい.
153
+ でそのdirをcleanにしておくことが望ましい.下のuninstallの項目を参照.
119
154
 
120
- 中身は以下の通り.
155
+ -mでやっている中身は以下の通り.
121
156
  <<< ruby
122
- desc "make own help from lib/daddygongon/files"
123
- task :my_help do
124
- exe_cont="#!/usr/bin/env ruby\n"
125
- user_name = 'daddygongon'
126
- p entries=Dir.entries(File.join('.','lib',user_name))[2..-1]
127
- entries.each{|file|
128
- p file
129
- p file_name=file.split('_')
130
- target_files = [file, file_name[0][0]+"_"+file_name[1][0]]
131
- p cont_name = File.join('lib',user_name,file)
132
- exe_cont << "require 'my_help'\n"
133
- exe_cont << "help_file = File.expand_path(\"../../#{cont_name}\", __FILE__)\n"
134
- exe_cont << "MyHelp::Command.run(help_file, ARGV)\n"
135
- target_files.each{|name|
136
- p ''
137
- p target=File.join('exe',name)
138
- File.open(target,'w'){|file|
139
- print exe_cont
140
- file.print exe_cont
157
+ def make_help
158
+ Dir.entries(@target_dir)[2..-1].each{|file|
159
+ next if file[0]=='#' or file[-1]=='~'
160
+ exe_cont="#!/usr/bin/env ruby\nrequire 'specific_help'\n"
161
+ exe_cont << "help_file = File.join(ENV['HOME'],'.my_help','#{file}')\n"
162
+ exe_cont << "SpecificHelp::Command.run(help_file, ARGV)\n"
163
+ [file, short_name(file)].each{|name|
164
+ p target=File.join('exe',name)
165
+ File.open(target,'w'){|file| file.print exe_cont}
166
+ FileUtils.chmod('a+x', target, :verbose => true)
167
+ }
141
168
  }
142
- FileUtils.chmod('a+x', target, :verbose => true)
143
- }
144
- }
145
- end
169
+ install_local
170
+ end
171
+
172
+ def install_local
173
+ #中略
174
+ system "git add -A"
175
+ system "git commit -m 'update exe dirs'"
176
+ system "Rake install:local"
177
+ end
178
+
146
179
  >>>
147
180
 
148
181
  実装方法は,emacs_helpに
@@ -154,10 +187,30 @@ end
154
187
  今の所,No.1の方を実装.No.2のためのhushデータは,
155
188
 
156
189
  <<< ruby
190
+ # -*- coding: utf-8 -*-
157
191
  require 'yaml'
158
192
  require 'pp'
159
-
160
- pp YAML.load(File.read(ARGV[0]))
193
+ yaml =<<EOF
194
+ :file:
195
+ :opts:
196
+ :short: "-f"
197
+ :cont:
198
+ - c-x c-f, Find file, ファイルを開く
199
+ - c-x c-s, Save file, ファイルを保存
200
+ EOF
201
+ pp data=YAML.load(yaml)
202
+ print YAML.dump(data)
203
+
204
+
205
+ data0={:file=>
206
+ {:opts=>{:short=>"-f", :long=>"--ファイル", :desc=>"File操作"},
207
+ :title=>"ファイル操作file",
208
+ :cont=>
209
+ ["c-x c-f, Find file, ファイルを開く
210
+ c-x c-s, Save file, ファイルを保存
211
+ c-x c-w, Write file NAME, ファイルを別名で書き込む"]}}
212
+
213
+ print YAML.dump(data0)
161
214
  >>>
162
215
 
163
216
  ruby test.rb lib/daddygongon/emacs_help
@@ -1,10 +1,12 @@
1
+ # -*- coding: utf-8 -*-
1
2
  ---
2
3
  #start header, which appears every time.
3
4
  :head: #never change
4
5
  - ヘルプのサンプル雛形 #describe the contents breafly.
5
6
  - " headに常に表示される内容を記述" #head '- ' is necessary
6
- :license: #never change
7
- - " cc by Shigeto R. Nishitani, 2016" #show licence
7
+ :license:
8
+ - " cc by Shigeto R. Nishitani, 2016"
9
+
8
10
  # start the first item
9
11
  :item: #change snake word
10
12
  :opts: #never change
@@ -14,16 +16,18 @@
14
16
  :title: 単元 #describe what for in each help
15
17
  :cont: #the following lines are appeared.
16
18
  - c-f, move Forwrard, 前or右へ #top ' - ' are necessary for yaml format
17
- - フォーマットは自由です.
19
+ - フォーマットは自由です.
18
20
 
19
21
  # start the second item... and so on.
20
- :item2:
21
- :opts:
22
- :short: -j
23
- :long: --item2
24
- :desc: 単元2(item2)
25
- :title: 単元2
22
+ :item2: #text here too
23
+ :opts:
24
+ :short: -c
25
+ :long: --word
26
+ :desc: text
27
+ :title: text
26
28
  :cont:
27
- - c-f, move Forwrard, 前or右へ
28
- - フォーマットは自由です.
29
+ - |
30
+ text line0
31
+ text line1
32
+
29
33
 
data/lib/emacs_help.rb ADDED
@@ -0,0 +1,122 @@
1
+ # -*- coding: utf-8 -*-
2
+ require "optparse"
3
+ require "emacs_help/version"
4
+
5
+ module EmacsHelp
6
+ class Command
7
+ def self.run(argv=[])
8
+ print "\n特殊キー操作"
9
+ print "\tc-f, controlキーを押しながら 'f'\n"
10
+ print "\t\tM-f, escキーを押した後一度離して'f'\n"
11
+ print "\t操作の中断c-g, 操作の取り消し(Undo) c-x u \n"
12
+ new(argv).execute
13
+ end
14
+
15
+ def initialize(argv=[])
16
+ @argv = argv
17
+ data_path = File.join(ENV['HOME'], '.hikirc')
18
+ end
19
+
20
+ def execute
21
+ @argv << '--help' if @argv.size==0
22
+ command_parser = OptionParser.new do |opt|
23
+ opt.on('-v', '--version','show program Version.') { |v|
24
+ opt.version = EmacsHelp::VERSION
25
+ puts opt.ver
26
+ }
27
+ opt.on('-c','--カーソル','Cursor移動') {cursor_move}
28
+ opt.on('-p','--ページ','Page移動') {page_move}
29
+ opt.on('-f','--ファイル','File操作') {file}
30
+ opt.on('-e','--編集','Edit操作') {edit}
31
+ opt.on('-w','--ウィンドウ','Window操作') {window}
32
+ opt.on('-b','--バッファ','Buffer操作') {buffer}
33
+ opt.on('-q','--終了','終了操作') {quit}
34
+ end
35
+ begin
36
+ command_parser.parse!(@argv)
37
+ rescue=> eval
38
+ p eval
39
+ end
40
+ exit
41
+ end
42
+
43
+ def disp(lines)
44
+ lines.each{|line|
45
+ if line.include?(',')
46
+ show line
47
+ else
48
+ puts " #{line}"
49
+ end
50
+ }
51
+ end
52
+ def show(line)
53
+ puts " #{line}"
54
+ end
55
+
56
+ def quit
57
+ puts "\n終了操作quit"
58
+ cont = ["c-x c-c, Quit emacs, ファイルを保存して終了",
59
+ "c-z, suspend emacs, 一時停止,fgで復活"]
60
+ disp(cont)
61
+ end
62
+
63
+ def window
64
+ puts "\nウィンドウ操作window"
65
+ cont=["c-x 2, 2 windows, 二つに分割",
66
+ "c-x 1, 1 windows, 一つに戻す",
67
+ "c-x 3, 3rd window sep,縦線分割",
68
+ "c-x o, Other windows, 次の画面へ移動"]
69
+ disp(cont)
70
+ end
71
+
72
+ def buffer
73
+ puts "\nバッファー操作buffer"
74
+ cont =[ "c-x b, show Buffer, バッファのリスト",
75
+ "c-x c-b, next Buffer, 次のバッファへ移動"]
76
+ disp(cont)
77
+ end
78
+
79
+ def edit
80
+ puts "\n編集操作editor"
81
+ cont = ["c-d, Delete char, 一字削除",
82
+ "c-k, Kill line, 一行抹消,カット",
83
+ "c-y, Yank, ペースト",
84
+ "c-w, Kill region, 領域抹消,カット",
85
+ "領域選択は,先頭or最後尾でc-spaceした後,最後尾or先頭へカーソル移動",
86
+ "c-s, forward incremental Search WORD, 前へWORDを検索",
87
+ "c-r, Reverse incremental search WORD, 後へWORDを検索",
88
+ "M-x query-replace WORD1 <ret> WORD2:対話的置換(y or nで可否選択)"]
89
+ disp(cont)
90
+ end
91
+
92
+ def file
93
+ puts "\nファイル操作file"
94
+ cont =[ "c-x c-f, Find file, ファイルを開く",
95
+ "c-x c-s, Save file, ファイルを保存",
96
+ "c-x c-w, Write file NAME, ファイルを別名で書き込む"]
97
+ disp(cont)
98
+ end
99
+
100
+ def page_move
101
+ puts "\nページ移動page"
102
+ cont = ["c-v, move Vertical, 次のページへ",
103
+ "M-v, move reversive Vertical,前のページへ",
104
+ "c-l, centerise Line, 現在行を中心に",
105
+ "M-<, move Top of file, ファイルの先頭へ",
106
+ "M->, move Bottom of file, ファイルの最後尾へ"]
107
+ disp(cont)
108
+ end
109
+
110
+ def cursor_move
111
+ puts "\nカーソル移動cursor"
112
+ cont = ["c-f, move Forwrard, 前or右へ",
113
+ "c-b, move Backwrard, 後or左へ",
114
+ "c-a, go Ahead of line, 行頭へ",
115
+ "c-e, go End of line, 行末へ",
116
+ "c-n, move Next line, 次行へ",
117
+ "c-p, move Previous line, 前行へ"]
118
+ disp(cont)
119
+ end
120
+
121
+ end
122
+ end