shakyo 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/.gitignore +19 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +35 -0
- data/Rakefile +2 -0
- data/bin/shakyo +10 -0
- data/lib/shakyo/version.rb +3 -0
- data/lib/shakyo.rb +69 -0
- data/shakyo.gemspec +20 -0
- metadata +56 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2012 Yusuke Kawamoto
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Shakyo
|
|
2
|
+
|
|
3
|
+
写経する為のプログラムです。
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
$ gem install shakyo
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
$ shakyo ./hello.c
|
|
12
|
+
|
|
13
|
+
## Howto
|
|
14
|
+
#include<stdio.h>
|
|
15
|
+
|
|
16
|
+
->int main(void)
|
|
17
|
+
{
|
|
18
|
+
printf("hello! world!\n");
|
|
19
|
+
return 0;
|
|
20
|
+
}
|
|
21
|
+
----------------
|
|
22
|
+
->int main(void)
|
|
23
|
+
> int main(vo
|
|
24
|
+
./hello.c:3/8 (COMMAND LIST: next prev quit)
|
|
25
|
+
|
|
26
|
+
* (該当行を入力)[Enter]
|
|
27
|
+
* 次の行へ移ります
|
|
28
|
+
* next[Enter]
|
|
29
|
+
* 次の行へ移ります
|
|
30
|
+
* prev[Enter]
|
|
31
|
+
* 前の行へ移ります
|
|
32
|
+
* quit[Enter]
|
|
33
|
+
* 終了します
|
|
34
|
+
* [Up Key][Down Key]
|
|
35
|
+
* 入力履歴にアクセスします
|
data/Rakefile
ADDED
data/bin/shakyo
ADDED
data/lib/shakyo.rb
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
#coding: utf-8
|
|
2
|
+
require "shakyo/version"
|
|
3
|
+
require "readline"
|
|
4
|
+
require "curses"
|
|
5
|
+
require "io/console"
|
|
6
|
+
|
|
7
|
+
module Shakyo
|
|
8
|
+
class Viewer
|
|
9
|
+
def initialize(filename)
|
|
10
|
+
@filename=filename
|
|
11
|
+
@source_lines=IO.readlines(@filename)
|
|
12
|
+
@pos=0
|
|
13
|
+
end
|
|
14
|
+
def line_view(pos)
|
|
15
|
+
if 0<=pos && pos<@source_lines.length
|
|
16
|
+
@source_lines[pos]
|
|
17
|
+
else
|
|
18
|
+
""
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
def my_readline
|
|
22
|
+
Curses.clear
|
|
23
|
+
Curses.refresh
|
|
24
|
+
center=10
|
|
25
|
+
(0..(Curses.lines-5)).each do |i|
|
|
26
|
+
Curses.setpos(i, 0)
|
|
27
|
+
Curses.addstr("#{i==center ? "->" : " "}#{line_view(@pos+i-10)}")
|
|
28
|
+
end
|
|
29
|
+
Curses.setpos(Curses.lines-4, 0)
|
|
30
|
+
Curses.addstr("----------------")
|
|
31
|
+
Curses.setpos(Curses.lines-3, 0)
|
|
32
|
+
Curses.addstr("->#{line_view(@pos)}")
|
|
33
|
+
Curses.setpos(Curses.lines - 1, 0)
|
|
34
|
+
Curses.addstr(
|
|
35
|
+
"#{@filename}:#{@pos+1}/#{@source_lines.length+1}"+
|
|
36
|
+
" (COMMAND LIST: next prev quit)"
|
|
37
|
+
)
|
|
38
|
+
Curses.setpos(Curses.lines - 2, 0)
|
|
39
|
+
Curses.refresh
|
|
40
|
+
Readline.readline("> ",true)
|
|
41
|
+
end
|
|
42
|
+
def eof?
|
|
43
|
+
@source_lines.length <= @pos
|
|
44
|
+
end
|
|
45
|
+
def run
|
|
46
|
+
Curses.init_screen
|
|
47
|
+
begin
|
|
48
|
+
IO.console.echo=true
|
|
49
|
+
while buf = my_readline
|
|
50
|
+
case buf.chomp
|
|
51
|
+
when "prev"
|
|
52
|
+
@pos-=1
|
|
53
|
+
when "next"
|
|
54
|
+
@pos+=1
|
|
55
|
+
when "quit"
|
|
56
|
+
break
|
|
57
|
+
when @source_lines[@pos].chomp
|
|
58
|
+
@pos+=1
|
|
59
|
+
end
|
|
60
|
+
if eof?
|
|
61
|
+
break
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
ensure
|
|
65
|
+
Curses.close_screen
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
data/shakyo.gemspec
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
require File.expand_path('../lib/shakyo/version', __FILE__)
|
|
3
|
+
|
|
4
|
+
Gem::Specification.new do |gem|
|
|
5
|
+
gem.authors = ["Yusuke Kawamoto"]
|
|
6
|
+
gem.email = ["novogrammer@gmail.com"]
|
|
7
|
+
gem.description = %q{Script for sourcecode transcription}
|
|
8
|
+
gem.summary = %q{Script for sourcecode transcription}
|
|
9
|
+
gem.homepage = ""
|
|
10
|
+
|
|
11
|
+
gem.files = `git ls-files`.split($\)
|
|
12
|
+
# gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
|
13
|
+
gem.executables = ["shakyo"]
|
|
14
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
|
15
|
+
gem.name = "shakyo"
|
|
16
|
+
gem.require_paths = ["lib"]
|
|
17
|
+
gem.version = Shakyo::VERSION
|
|
18
|
+
gem.required_ruby_version = '>= 1.9.3'
|
|
19
|
+
|
|
20
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: shakyo
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
prerelease:
|
|
6
|
+
platform: ruby
|
|
7
|
+
authors:
|
|
8
|
+
- Yusuke Kawamoto
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2012-08-05 00:00:00.000000000 Z
|
|
13
|
+
dependencies: []
|
|
14
|
+
description: Script for sourcecode transcription
|
|
15
|
+
email:
|
|
16
|
+
- novogrammer@gmail.com
|
|
17
|
+
executables:
|
|
18
|
+
- shakyo
|
|
19
|
+
extensions: []
|
|
20
|
+
extra_rdoc_files: []
|
|
21
|
+
files:
|
|
22
|
+
- .gitignore
|
|
23
|
+
- Gemfile
|
|
24
|
+
- LICENSE
|
|
25
|
+
- README.md
|
|
26
|
+
- Rakefile
|
|
27
|
+
- bin/shakyo
|
|
28
|
+
- lib/shakyo.rb
|
|
29
|
+
- lib/shakyo/version.rb
|
|
30
|
+
- shakyo.gemspec
|
|
31
|
+
homepage: ''
|
|
32
|
+
licenses: []
|
|
33
|
+
post_install_message:
|
|
34
|
+
rdoc_options: []
|
|
35
|
+
require_paths:
|
|
36
|
+
- lib
|
|
37
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
38
|
+
none: false
|
|
39
|
+
requirements:
|
|
40
|
+
- - ! '>='
|
|
41
|
+
- !ruby/object:Gem::Version
|
|
42
|
+
version: 1.9.3
|
|
43
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
44
|
+
none: false
|
|
45
|
+
requirements:
|
|
46
|
+
- - ! '>='
|
|
47
|
+
- !ruby/object:Gem::Version
|
|
48
|
+
version: '0'
|
|
49
|
+
requirements: []
|
|
50
|
+
rubyforge_project:
|
|
51
|
+
rubygems_version: 1.8.24
|
|
52
|
+
signing_key:
|
|
53
|
+
specification_version: 3
|
|
54
|
+
summary: Script for sourcecode transcription
|
|
55
|
+
test_files: []
|
|
56
|
+
has_rdoc:
|