Class: Ruber::CommandPlugin::Output
Overview
Fake IO object for use by the command plugin. Despite the name, it can be used to display standard error as well as standard output.
It displays the text in a Qt::PlainTextEdit
using a given color.
All the methods in this class are implementations of the API provided by IO.
Instance Attribute Summary (collapse)
-
- (Boolean) sync
Whether byffering is disabled or enabled.
Instance Method Summary (collapse)
-
- (Output) <<(text)
As
IO#<<
. -
- (nil) binmode
As
IO#binmode
. -
- (TrueClass) binmode?
As
IO#binmode?
. -
- (Enumerator) bytes
As
IO#bytes
. -
- (Enumerator) chars
As
IO#chars
. -
- (nil) close
As
IO#close
. -
- (Object) close_on_exec(val)
As
IO#close_on_exec
. -
- (Boolean) close_on_exec?
As
IO#close_on_exec?
. -
- (nil) close_read
As
IO#close_read
. -
- (nil) close_write
As
IO#close_write
. -
- (Boolean) closed?
As
IO#closed?
. -
- (Enumerator) each
As
IO#each
. -
- (Enumerator) each_byte
As
IO#each_byte
. -
- (Enumerator) each_char
As
IO#each_char
. -
- (Enumerator) each_line(sep)
As
IO#each
. -
- (nil) eof
As
IO#eof
. -
- (nil) eof?
As
IO#eof?
. -
- (nil) external_encoding
As
IO#external_encoding
. -
- (Integer) fileno
As
IO#fileno
. -
- (Output) flush
As
IO#flush
. -
- (nil) getbyte
As
IO#getbyte
. -
- (nil) getc
As
IO#getc
. -
- (nil) gets
As
IO#gets
. -
- (Output) initialize(widget, color, fileno = 1)
constructor
A new instance of Output.
-
- (nil) internal_encoding
As
IO#internal_encoding
. -
- (false) isatty
(also: #tty?)
As
IO#isatty
. -
- (nil) lineno
As
IO#lineno
. -
- (nil) lineno(val)
As
IO#lineno=
. -
- (Enumerator) lines
As
IO#lines
. -
- (nil) pid
As
IO#pid
. -
- (nil) print(*args)
As
IO#print
. -
- (nil) printf(format_string, *args)
As
IO#printf
. -
- (Object) putc(obj)
As
IO#putc
. -
- (nil) puts(*args)
As
IO#puts
. -
- (nil) read(length, buffer = nil)
As
IO#read
. -
- (nil) read_nonblock(max, outbuf = nil)
As
IO#read_nonblock
. -
- (nil) readbyte
As
IO#readbyte
. -
- (nil) readchar
As
IO#readchar
. -
- (nil) readline(sep, limit)
As
IO#readline
. -
- (nil) readlines(sep, limit)
As
IO#readlines
. -
- (nil) readpartial(maxlen, outbuf = nil)
As
IO#readpartial
. -
- (nil) reopen(arg1, arg2 = 'r')
As
IO#reopen
. -
- (Object) set_encoding(*args)
As
IO#set_encoding
. -
- (nil) stat
As
IO#stat
. -
- (nil) sysread(num, outbuf = nil)
As
IO#sysread
. -
- (Output) to_io
As
IO#to_io
. -
- (nil) ungetbyte(arg)
As
IO#ungetbyte
. -
- (nil) ungetc(str)
As
IO#ungetc
. -
- (Integer) write(obj)
(also: #syswrite, #write_nonblock)
As
IO#write
.
Constructor Details
- (Output) initialize(widget, color, fileno = 1)
A new instance of Output
47 48 49 50 51 52 53 54 |
# File 'plugins/command/output.rb', line 47 def initialize , color, fileno = 1 @widget = @close_on_exec = false @closed = false @sync = true @brush = Qt::Brush.new color @fileno = fileno end |
Instance Attribute Details
- (Boolean) sync
Whether byffering is disabled or enabled. This class doesn’t buffer
output, so this makes no difference. It’s only provided for compatibility with
IO
API
61 62 63 |
# File 'plugins/command/output.rb', line 61 def sync @sync end |
Instance Method Details
- (Output) <<(text)
As IO#<<
68 69 70 71 |
# File 'plugins/command/output.rb', line 68 def << text write text self end |
- (nil) binmode
As IO#binmode
This method doesn’t actually do anything. It’s just for compatibility with the IO
API
80 81 |
# File 'plugins/command/output.rb', line 80 def binmode end |
- (TrueClass) binmode?
As IO#binmode?
This method always returns true. It’s just for compatibility with the IO
API
90 91 92 |
# File 'plugins/command/output.rb', line 90 def binmode? true end |
- (Enumerator) bytes
As IO#bytes
99 100 101 |
# File 'plugins/command/output.rb', line 99 def bytes each_byte end |
- (Enumerator) chars
As IO#chars
109 110 111 |
# File 'plugins/command/output.rb', line 109 def chars each_char end |
- (nil) close
As IO#close
118 119 120 121 |
# File 'plugins/command/output.rb', line 118 def close @closed = true nil end |
- (Object) close_on_exec=(val)
As IO#close_on_exec
This method does nothing. It’s only for compatibility with IO
API
131 132 133 |
# File 'plugins/command/output.rb', line 131 def close_on_exec= val @close_on_exec = val.to_bool end |
- (Boolean) close_on_exec?
As IO#close_on_exec?
#close_on_exec= has no influence on this class, so the value returned here is
meaningless. It’s only provided for compatibility with IO
API
143 144 145 |
# File 'plugins/command/output.rb', line 143 def close_on_exec? @close_on_exec end |
- (nil) close_read
As IO#close_read
153 154 155 |
# File 'plugins/command/output.rb', line 153 def close_read raise IOError, 'closing non-duplex IO for reading' end |
- (nil) close_write
As IO#close_write
162 163 164 165 |
# File 'plugins/command/output.rb', line 162 def close_write @closed = true nil end |
- (Boolean) closed?
As IO#closed?
172 173 174 |
# File 'plugins/command/output.rb', line 172 def closed? @closed end |
- (Enumerator) each
As IO#each
182 183 184 185 |
# File 'plugins/command/output.rb', line 182 def each raise IOError, "not opened for reading" if block_given? to_enum end |
- (Enumerator) each_byte
As IO#each_byte
193 194 195 196 |
# File 'plugins/command/output.rb', line 193 def each_byte raise IOError, "not opened for reading" if block_given? to_enum :each_byte end |
- (Enumerator) each_char
As IO#each_char
204 205 206 207 |
# File 'plugins/command/output.rb', line 204 def each_char raise IOError, "not opened for reading" if block_given? to_enum :each_char end |
- (Enumerator) each_line(sep)
As IO#each
215 216 217 218 |
# File 'plugins/command/output.rb', line 215 def each_line sep raise IOError, "not opened for reading" if block_given? to_enum :each_line end |
- (nil) eof
As IO#eof
226 227 228 |
# File 'plugins/command/output.rb', line 226 def eof raise IOError, "not opened for reading" end |
- (nil) eof?
As IO#eof?
236 237 238 |
# File 'plugins/command/output.rb', line 236 def eof? raise IOError, "not opened for reading" end |
- (nil) external_encoding
As IO#external_encoding
245 246 247 |
# File 'plugins/command/output.rb', line 245 def external_encoding nil end |
- (Integer) fileno
As IO#fileno
254 255 256 |
# File 'plugins/command/output.rb', line 254 def fileno @fileno end |
- (Output) flush
As IO#flush
As this class doesn’t do any buffering, this method does nothing and is only
provided for compatibility with IO
API
266 267 268 |
# File 'plugins/command/output.rb', line 266 def flush self end |
- (nil) getbyte
As IO#getbyte
276 277 278 |
# File 'plugins/command/output.rb', line 276 def getbyte raise IOError, "not opened for reading" end |
- (nil) getc
As IO#getc
286 287 288 |
# File 'plugins/command/output.rb', line 286 def getc raise IOError, "not opened for reading" end |
- (nil) gets
As IO#gets
296 297 298 |
# File 'plugins/command/output.rb', line 296 def gets raise IOError, "not opened for reading" end |
- (nil) internal_encoding
As IO#internal_encoding
305 306 307 |
# File 'plugins/command/output.rb', line 305 def internal_encoding nil end |
- (false) isatty Also known as: tty?
As IO#isatty
314 315 316 |
# File 'plugins/command/output.rb', line 314 def isatty false end |
- (nil) lineno
As IO#lineno
325 326 327 |
# File 'plugins/command/output.rb', line 325 def lineno raise IOError, "not opened for reading" end |
- (nil) lineno=(val)
As IO#lineno=
335 336 337 |
# File 'plugins/command/output.rb', line 335 def lineno= val raise IOError, "not opened for reading" end |
- (Enumerator) lines
As IO#lines
344 345 346 |
# File 'plugins/command/output.rb', line 344 def lines each_line end |
- (nil) pid
As IO#pid
353 354 355 |
# File 'plugins/command/output.rb', line 353 def pid nil end |
- (nil) print(*args)
As IO#print
363 364 365 366 367 368 369 |
# File 'plugins/command/output.rb', line 363 def print *args args = [$_] if args.empty? args.each{|a| write a} STDOUT.write $\ write $\ if $\ nil end |
- (nil) printf(format_string, *args)
As IO#printf
378 379 380 381 382 |
# File 'plugins/command/output.rb', line 378 def printf format_string, *args str = sprintf format_string, *args write str nil end |
- (Object) putc(obj)
As IO#putc
390 391 392 393 394 395 |
# File 'plugins/command/output.rb', line 390 def putc obj if obj.is_a? Numeric then write obj.floor.chr else obj.to_s.each_char.to_a[0] end obj end |
- (nil) puts(*args)
As IO#puts
403 404 405 406 407 408 409 410 411 |
# File 'plugins/command/output.rb', line 403 def puts *args args << '' if args.empty? args.each do |a| a = a.to_s write a write "\n" unless a.end_with? "\n" end nil end |
- (nil) read(length, buffer = nil)
As IO#read
421 422 423 |
# File 'plugins/command/output.rb', line 421 def read length, buffer = nil raise IOError, "not opened for reading" end |
- (nil) read_nonblock(max, outbuf = nil)
As IO#read_nonblock
433 434 435 |
# File 'plugins/command/output.rb', line 433 def read_nonblock max, outbuf = nil raise IOError, "not opened for reading" end |
- (nil) readbyte
As IO#readbyte
443 444 445 |
# File 'plugins/command/output.rb', line 443 def readbyte raise IOError, "not opened for reading" end |
- (nil) readchar
As IO#readchar
453 454 455 |
# File 'plugins/command/output.rb', line 453 def readchar raise IOError, "not opened for reading" end |
- (nil) readline(sep, limit)
As IO#readline
465 466 467 |
# File 'plugins/command/output.rb', line 465 def readline sep, limit raise IOError, "not opened for reading" end |
- (nil) readlines(sep, limit)
As IO#readlines
477 478 479 |
# File 'plugins/command/output.rb', line 477 def readlines sep, limit raise IOError, "not opened for reading" end |
- (nil) readpartial(maxlen, outbuf = nil)
As IO#readpartial
489 490 491 |
# File 'plugins/command/output.rb', line 489 def readpartial maxlen, outbuf = nil raise IOError, "not opened for reading" end |
- (nil) reopen(arg1, arg2 = 'r')
As IO#reopen
501 502 503 |
# File 'plugins/command/output.rb', line 501 def reopen arg1, arg2 = 'r' raise RuntimeError, "You can\'t reopen #{self.class}" end |
- (Object) set_encoding(*args)
As IO#set_encoding
This method does nothing. It’s only provided for compatibility with IO
API
511 512 |
# File 'plugins/command/output.rb', line 511 def set_encoding *args end |
- (nil) stat
As IO#stat
519 520 521 |
# File 'plugins/command/output.rb', line 519 def stat nil end |
- (nil) sysread(num, outbuf = nil)
As IO#sysread
531 532 533 |
# File 'plugins/command/output.rb', line 531 def sysread num, outbuf = nil raise IOError, "not opened for reading" end |
- (Output) to_io
As IO#to_io
540 541 542 |
# File 'plugins/command/output.rb', line 540 def to_io self end |
- (nil) ungetbyte(arg)
As IO#ungetbyte
551 552 553 |
# File 'plugins/command/output.rb', line 551 def ungetbyte arg raise IOError, "not opened for reading" end |
- (nil) ungetc(str)
As IO#ungetc
562 563 564 |
# File 'plugins/command/output.rb', line 562 def ungetc str raise IOError, "not opened for reading" end |
- (Integer) write(obj) Also known as: syswrite, write_nonblock
As IO#write
573 574 575 576 577 578 579 580 581 582 583 584 |
# File 'plugins/command/output.rb', line 573 def write obj if !@closed cur = @widget.text_cursor cur.move_position Qt::TextCursor::End text = obj.to_s format = cur.char_format format.foreground = @brush cur.insert_text text, format text.bytes.count else raise IOError, 'closed stream' end end |