jareditor 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 58c9412095e31e0a529236c326524633eb113219
4
- data.tar.gz: 5a59a2e58611e0f8fa37f14de67a66a376b4ea63
3
+ metadata.gz: 80a9dc0c47c5996efc1a2f972a7bd386df1b0ba8
4
+ data.tar.gz: fcb4d4a2be5618a9886d94c93de053722e46ff53
5
5
  SHA512:
6
- metadata.gz: 5c7b1014a3a187604df1ad84fc6b2d66dc9e637471eb6f45c792c7c318dfd2168ff3cd80fe4e852939e9ba2f3b4d699c160a51c7a8303ccfa7ea8775399b628b
7
- data.tar.gz: 0d534d05bbb7b0f6b956f9dee7736a7a8b080ce1f4a18594e1c8ba45005e13dfa6a599917d6e871b2c60b97fb7298fa9b8641116cda56e998de73c241ac179ce
6
+ metadata.gz: dcef45d4611e3301c79d8597fcf4f6aa44fb7482567105ed8dc37af47a2dee9f715bce0f3244adfa0d28b065a0c7e7ee1303fb2daef2160409d1150e07be7164
7
+ data.tar.gz: 8482fd9cad5da24d0677e1e990e79d56de967ccada9059171bc535682b16bcac0c7601369a55e9e2ee381dbf0f5de8188ac4b1857c68920159a49cc76f2e5c8d
data/lib/jared.rb CHANGED
@@ -1,15 +1,16 @@
1
1
  require "curses"
2
2
  require "jared/version"
3
+ require "jared/pane"
4
+ require "jared/buffer"
3
5
 
4
6
  module JarEd
5
7
  class << self
6
8
  def start(args)
7
- with_screen do
8
- loop do
9
- stop! if Curses.getch == 'q'
10
- Curses.doupdate
11
- break if stop
12
- end
9
+ pane.buffer = Buffer.new File.open(args[0], "r")
10
+
11
+ take_input do |char|
12
+ pane.refresh(window)
13
+ break if char == "\e"
13
14
  end
14
15
  end
15
16
 
@@ -17,20 +18,30 @@ module JarEd
17
18
  "Jared Norman"
18
19
  end
19
20
 
20
- def stop!
21
- @stop = true
22
- end
23
-
24
21
  private
25
22
 
26
- attr_reader :stop
23
+ def pane
24
+ @pane ||= Pane.new
25
+ end
26
+
27
+ def window
28
+ @window ||= Curses::Window.new(Curses.lines, Curses.cols, 0, 0)
29
+ end
27
30
 
28
- def with_screen
31
+ def take_input
29
32
  Curses.init_screen
30
33
  begin
31
34
  Curses.crmode
32
35
  Curses.noecho
33
- yield
36
+
37
+ Curses.refresh
38
+ yield nil
39
+ Curses.doupdate
40
+
41
+ loop do
42
+ yield Curses.getch.chr
43
+ Curses.doupdate
44
+ end
34
45
  ensure
35
46
  Curses.close_screen
36
47
  end
@@ -0,0 +1,22 @@
1
+ module JarEd
2
+ class Buffer
3
+ attr_reader :window_position,
4
+ :cursor_line,
5
+ :cursor_column
6
+
7
+ def initialize(file)
8
+ @file = file
9
+ @window_position = 0
10
+ @cursor_line = 0
11
+ @cursor_column = 0
12
+ end
13
+
14
+ def lines
15
+ @lines ||= file.each_line.to_a
16
+ end
17
+
18
+ private
19
+
20
+ attr_reader :file
21
+ end
22
+ end
data/lib/jared/pane.rb ADDED
@@ -0,0 +1,20 @@
1
+ module JarEd
2
+ class Pane
3
+ attr_accessor :buffer
4
+
5
+ def refresh(window)
6
+ window.setpos(0, 0)
7
+ draw_lines(window)
8
+ window.noutrefresh
9
+ end
10
+
11
+ private
12
+
13
+ def draw_lines(window)
14
+ buffer.lines.each do |line|
15
+ # line_height = line.scan(/.{1,#{Curses.cols}}/)
16
+ window.addstr line
17
+ end
18
+ end
19
+ end
20
+ end
data/lib/jared/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module JarEd
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jareditor
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jared Norman
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-03-19 00:00:00.000000000 Z
11
+ date: 2016-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: curses
@@ -127,6 +127,8 @@ files:
127
127
  - exe/jared
128
128
  - jareditor.gemspec
129
129
  - lib/jared.rb
130
+ - lib/jared/buffer.rb
131
+ - lib/jared/pane.rb
130
132
  - lib/jared/version.rb
131
133
  homepage: https://github.com/jarednorman/jared
132
134
  licenses: []