- #
- B
- C
- D
- E
- F
- G
- I
- L
- O
- P
-
- pid,
- pos,
- pos=,
- pos_gravity,
- pos_gravity=,
- print,
- printf,
- putc,
- puts
- R
- S
- T
-
- tell,
- tell_index,
- to_io,
- trancate,
- tty?
- U
- W
| OPT_DEFAULTS | = | { 'mode' => nil, 'overwrite' => false, 'text' => nil, 'show' => :pos, 'wrap' => 'char', 'sync' => true, 'prompt' => nil, 'prompt_cmd' => nil, 'hist_size' => 1000, } |
Source: show
# File ext/tk/sample/tktextio.rb, line 397 def <<(obj) _write(obj) self end
Source: show
# File ext/tk/sample/tktextio.rb, line 406 def clone fail NotImplementedError, 'cannot clone TkTextIO' end
Source: show
# File ext/tk/sample/tktextio.rb, line 413 def close close_read close_write nil end
Source: show
# File ext/tk/sample/tktextio.rb, line 418 def close_read @open[:r] = false if @open[:r] nil end
Source: show
# File ext/tk/sample/tktextio.rb, line 422 def close_write @open[:w] = false if @opne[:w] nil end
Source: show
# File ext/tk/sample/tktextio.rb, line 427 def closed?(dir=nil) case dir when :r, 'r' !@open[:r] when :w, 'w' !@open[:w] else !@open[:r] && !@open[:w] end end
Source: show
# File ext/tk/sample/tktextio.rb, line 75 def destroy @flusher.kill rescue nil @idle_flush.stop rescue nil @timer_flush.stop rescue nil @receiver.kill rescue nil super() end
Source: show
# File ext/tk/sample/tktextio.rb, line 409 def dup fail NotImplementedError, 'cannot duplicate TkTextIO' end
Source: show
# File ext/tk/sample/tktextio.rb, line 457 def each_char _check_readable while(c = self.getc) yield(c) end self end
Source: show
# File ext/tk/sample/tktextio.rb, line 448 def each_line(rs = $/) _check_readable while(s = self.gets(rs)) yield(s) end self end
Source: show
# File ext/tk/sample/tktextio.rb, line 466 def eof? compare(@txtpos, '==', 'end - 1 char') end
Source: show
# File ext/tk/sample/tktextio.rb, line 471 def fcntl(*args) fail NotImplementedError, "fcntl is not implemented on #{self.class}" end
Source: show
# File ext/tk/sample/tktextio.rb, line 483 def flush Thread.pass if @open[:w] || ! @write_buffer.empty? @write_buf_mutex.synchronize { _sync_write_buf(@write_buffer) @write_buffer[0..-1] = '' } end self end
Source: show
# File ext/tk/sample/tktextio.rb, line 494 def getc return _block_read(1) if @console_mode _check_readable return nil if eof? c = get(@txtpos) @txtpos.set(@txtpos + '1 char') _see_pos c end
Source: show
# File ext/tk/sample/tktextio.rb, line 505 def gets(rs = $/) return _block_read(rs) if @console_mode _check_readable return nil if eof? _readline(rs) end
Source: show
# File ext/tk/sample/tktextio.rb, line 545 def index_pos index(@txtpos) end
Source: show
# File ext/tk/sample/tktextio.rb, line 550 def index_pos=(idx) @txtpos.set(idx) @txtpos.set('end - 1 char') if compare(@txtpos, '>=', :end) _see_pos idx end
Source: show
# File ext/tk/sample/tktextio.rb, line 513 def ioctrl(*args) fail NotImplementedError, 'iocntl is not implemented on TkTextIO' end
Source: show
# File ext/tk/sample/tktextio.rb, line 524 def lineno @lineno + @line_offset end
Source: show
# File ext/tk/sample/tktextio.rb, line 528 def lineno=(num) @line_offset = num - @lineno num end
Source: show
# File ext/tk/sample/tktextio.rb, line 537 def overwrite=(ovwt) @overwrite = (ovwt)? true: false end
Source: show
# File ext/tk/sample/tktextio.rb, line 533 def overwrite? @overwrite end
Source: show
# File ext/tk/sample/tktextio.rb, line 557 def pos s = get('1.0', @txtpos) number(tk_call('string', 'length', s)) end
Source: show
# File ext/tk/sample/tktextio.rb, line 563 def pos=(idx) seek(idx, IO::SEEK_SET) idx end
Source: show
# File ext/tk/sample/tktextio.rb, line 568 def pos_gravity @txtpos.gravity end
Source: show
# File ext/tk/sample/tktextio.rb, line 572 def pos_gravity=(side) @txtpos.gravity = side side end
Source: show
# File ext/tk/sample/tktextio.rb, line 577 def print(arg=$_, *args) _check_writable args.unshift(arg) args.map!{|val| (val == nil)? 'nil': val.to_s } str = args.join($,) str << $\ if $\ _write(str) nil end
Source: show
# File ext/tk/sample/tktextio.rb, line 586 def printf(*args) _check_writable _write(sprintf(*args)) nil end
Source: show
# File ext/tk/sample/tktextio.rb, line 592 def putc(c) _check_writable c = c.chr if c.kind_of?(Fixnum) _write(c) c end
Source: show
# File ext/tk/sample/tktextio.rb, line 599 def puts(*args) _check_writable if args.empty? _write("\n") return nil end args.each{|arg| if arg == nil _write("nil\n") elsif arg.kind_of?(Array) puts(*arg) elsif arg.kind_of?(String) _write(arg.chomp) _write("\n") else begin arg = arg.to_ary puts(*arg) rescue puts(arg.to_s) end end } nil end
Source: show
# File ext/tk/sample/tktextio.rb, line 635 def read(len=nil, buf=nil) return _block_read(len, buf) if @console_mode _check_readable if len return "" if len == 0 return nil if eof? s = _read(len) else s = get(@txtpos, 'end - 1 char') @txtpos.set('end - 1 char') _see_pos end buf.replace(s) if buf.kind_of?(String) s end
Source: show
# File ext/tk/sample/tktextio.rb, line 652 def readchar return _block_read(1) if @console_mode _check_readable fail EOFError if eof? c = get(@txtpos) @txtpos.set(@txtpos + '1 char') _see_pos c end
Source: show
# File ext/tk/sample/tktextio.rb, line 698 def readline(rs = $/) return _block_readline(rs) if @console_mode _check_readable fail EOFError if eof? _readline(rs) end
Source: show
# File ext/tk/sample/tktextio.rb, line 706 def readlines(rs = $/) if @console_mode lines = [] while (line = _block_readline(rs)) lines << line end return lines end _check_readable lines = [] until(eof?) lines << _readline(rs) end $_ = nil lines end
Source: show
# File ext/tk/sample/tktextio.rb, line 724 def readpartial(maxlen, buf=nil) #return @console_buffer.readpartial(maxlen, buf) if @console_mode return _block_read(maxlen, buf, nil) if @console_mode _check_readable fail EOFError if eof? s = _read(maxlen) buf.replace(s) if buf.kind_of?(String) s end
Source: show
# File ext/tk/sample/tktextio.rb, line 735 def reopen(*args) fail NotImplementedError, 'reopen is not implemented on TkTextIO' end
Source: show
# File ext/tk/sample/tktextio.rb, line 739 def rewind @txtpos.set('1.0') _see_pos @lineno = 0 @line_offset = 0 self end
Source: show
# File ext/tk/sample/tktextio.rb, line 747 def seek(offset, whence=IO::SEEK_SET) case whence when IO::SEEK_SET offset = "1.0 + #{offset} char" if offset.kind_of?(Numeric) @txtpos.set(offset) when IO::SEEK_CUR offset = "#{offset} char" if offset.kind_of?(Numeric) @txtpos.set(@txtpos + offset) when IO::SEEK_END offset = "#{offset} char" if offset.kind_of?(Numeric) @txtpos.set("end - 1 char + #{offset}") else fail Errno::EINVAL, 'invalid whence argument' end @txtpos.set('end - 1 char') if compare(@txtpos, '>=', :end) _see_pos 0 end
Source: show
# File ext/tk/sample/tktextio.rb, line 777 def show_mode (@show == @txtpos)? :pos : @show end
Source: show
# File ext/tk/sample/tktextio.rb, line 781 def show_mode=(mode) # define show mode when file position is changed. # mode == :pos or "pos" or true :: see current file position. # mode == :insert or "insert" :: see insert cursor position. # mode == nil or false :: do nothing # else see 'mode' position ('mode' should be text index or mark) case mode when :pos, 'pos', true @show = @txtpos when :insert, 'insert' @show = :insert when nil, false @show = false else begin index(mode) rescue fail ArgumentError, 'invalid show-position' end @show = mode end _see_pos mode end
Source: show
# File ext/tk/sample/tktextio.rb, line 808 def stat fail NotImplementedError, 'stat is not implemented on TkTextIO' end
Source: show
# File ext/tk/sample/tktextio.rb, line 816 def sync=(mode) @sync = mode end
Source: show
# File ext/tk/sample/tktextio.rb, line 820 def sysread(len, buf=nil) return _block_read(len, buf) if @console_mode _check_readable fail EOFError if eof? s = _read(len) buf.replace(s) if buf.kind_of?(String) s end
Source: show
# File ext/tk/sample/tktextio.rb, line 830 def syswrite(obj) _write(obj) end
Source: show
# File ext/tk/sample/tktextio.rb, line 838 def trancate(len) delete("1.0 + #{len} char", :end) 0 end
Source: show
# File ext/tk/sample/tktextio.rb, line 843 def ungetc(c) if @console_mode @read_buf_mutex.synchronize { @read_buffer[0,0] = c.chr } return nil end _check_readable c = c.chr if c.kind_of?(Fixnum) if compare(@txtpos, '>', '1.0') @txtpos.set(@txtpos - '1 char') delete(@txtpos) insert(@txtpos, tk_call('string', 'range', c, 0, 1)) @txtpos.set(@txtpos - '1 char') if @txtpos.gravity == 'right' _see_pos else fail IOError, 'cannot ungetc at head of stream' end nil end