Class: EmacsHelp::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/emacs_help.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv = []) ⇒ Command



15
16
17
18
# File 'lib/emacs_help.rb', line 15

def initialize(argv=[])
  @argv = argv
  data_path = File.join(ENV['HOME'], '.hikirc')
end

Class Method Details

.run(argv = []) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/emacs_help.rb', line 7

def self.run(argv=[])
  print "\n 特殊キー操作:"
  print "c-f, controlキーを押しながらf, "
  print "M-f, escキーを押した後一度離してf\n"
  print " 操作の中断c-g, 操作の取り消し(Undo) c-x u \n\n"
  new(argv).execute
end

Instance Method Details

#bufferObject



70
71
72
73
74
# File 'lib/emacs_help.rb', line 70

def buffer
  cont =[ "c-x b, show Buffer, バッファのリスト",
          "c-x c-b, next Buffer, 次のバッファへ移動"]
  disp(cont)
end

#bulk_moveObject



95
96
97
98
99
100
101
102
# File 'lib/emacs_help.rb', line 95

def bulk_move
  cont = ["c-v, move Vertical,    次のページへ",
          "M-v, move ,   前のページへ",
          "c-l, centrise Line, 現在行を中心に",
          "M-<, move Top of file, ファイルの先頭へ",
          "M->, move Bottom of file, ファイルの最後尾へ"]
  disp(cont)
end

#cursor_moveObject



104
105
106
107
108
109
110
111
112
# File 'lib/emacs_help.rb', line 104

def cursor_move
  cont = ["c-f, move Forwrard,    前・右へ",
          "c-b, move Backwrard,   後・左へ",
          "c-a, go Ahead of line, 行頭へ",
          "c-e, go End of line,   行末へ",
          "c-n, move Next line,   次行へ",
          "c-p, move Previous line, 前行へ"]
  disp(cont)
end

#disp(lines) ⇒ Object



43
44
45
46
47
48
49
50
51
# File 'lib/emacs_help.rb', line 43

def disp(lines)
  lines.each{|line|
    if line.include?(',')
      show line
    else
      puts line
    end
  }
end

#editObject



76
77
78
79
80
81
82
83
84
85
86
# File 'lib/emacs_help.rb', line 76

def edit
  cont = ["c-d, Delete char, 一字削除",
          "c-k, Kill line, 一行抹消,カット",
          "c-y, Yank, ペースト",
          "c-w, Kill region, 領域抹消,カット",
          "領域選択は,先頭でc-spaceした後,最後尾へカーソル移動",
          "c-s, forward Search WORD, 前へWORDを検索",
          "c-r, Reverse search WORD, 後ろへWORDを検索",
          "M-x query-replace WORD1 <return> WORD2:一括置換(y or nで選択)"]
  disp(cont)
end

#executeObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/emacs_help.rb', line 20

def execute
  @argv << '--help' if @argv.size==0
  command_parser = OptionParser.new do |opt|
    opt.on('-v', '--version','show program Version.') { |v|
      opt.version = EmacsHelp::VERSION
      puts opt.ver
    }
    opt.on('-c','--カーソル','Cursor移動') {cursor_move}
    opt.on('-p','--ページ','Page移動') {bulk_move}
    opt.on('-f','--ファイル','File操作') {file}
    opt.on('-e','--編集','Edit操作') {edit}
    opt.on('-w','--ウィンドウ','Window操作') {window}
    opt.on('-b','--バッファ','Buffer操作') {buffer}
    opt.on('-q','--終了','終了操作') {quit}
  end
  begin
    command_parser.parse!(@argv)
  rescue=> eval
    p eval
  end
  exit
end

#fileObject



88
89
90
91
92
93
# File 'lib/emacs_help.rb', line 88

def file
  cont =[ "c-x c-f, Fine file, ファイルを開く",
          "c-x c-s, Save file, ファイルを保存",
          "c-x c-w, Write file NAME, ファイルを別名で書き込む"]
  disp(cont)
end

#quitObject



56
57
58
59
60
# File 'lib/emacs_help.rb', line 56

def quit
  cont = ["c-x c-c, Quit emacs, ファイルを保存して終了",
          "c-z, suspend emacs, 一時停止,fgで復活"]
  disp(cont)
end

#show(line) ⇒ Object



52
53
54
# File 'lib/emacs_help.rb', line 52

def show(line)
  puts "\t#{line}"
end

#windowObject



62
63
64
65
66
67
68
# File 'lib/emacs_help.rb', line 62

def window
  cont=["c-x 2, 2 windows, 二つに分割",
        "c-x 1, 1 windows, 一つに戻す",
        "c-x 3,  windows, 縦線分割",
        "c-x o, Other windows, 次の画面へ移動"]
  disp(cont)
end