Sha256: 6d2a6ab840a1ca89d1b3aea477575d00e53808a3e0c354e7201a2ced5e1dfb2b
Contents?: true
Size: 1.24 KB
Versions: 1
Compression:
Stored size: 1.24 KB
Contents
#!/usr/bin/env ruby require 'curses' $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__) require 'ruco' def write(line,row,text) Curses.setpos(line,row) Curses.addstr(text); end def init_screen Curses.noecho # do not show typed chars Curses.init_screen Curses.stdscr.keypad(true) # enable arrow keys Curses.raw # give us all other keys begin yield ensure Curses.close_screen end end editor = Ruco::Editor.new(ARGV[0], :lines => Curses.stdscr.maxy, :columns => Curses.stdscr.maxx) init_screen do loop do lines = editor.view.split("\n") Curses.stdscr.maxy.times do |i| line = lines[i] || '' clearer = Curses.stdscr.maxx - line.size clearer = " " * clearer write(i, 0, line + clearer) end Curses.setpos(editor.cursor_line, editor.cursor_column) key = Curses.getch case key when Curses::Key::UP then editor.move(-1,0) when Curses::Key::DOWN then editor.move(1,0) when Curses::Key::RIGHT then editor.move(0,1) when Curses::Key::LEFT then editor.move(0,-1) when 32..126 then editor.insert(key.chr) # printable when 10 then editor.insert("\n") # enter when 263 then editor.delete(-1) # backspace when ?\C-w, ?\C-q then break # quit end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ruco-0.0.1 | bin/ruco |