Created
July 4, 2014 17:26
-
-
Save stevengj/88502943fe0478933492 to your computer and use it in GitHub Desktop.
LoggingTerminal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Base.Terminals: TextTerminal, writepos, cmove, getX, getY, reseteof, cmove_up, cmove_down, cmove_left, cmove_right, cmove_line_up, cmove_line_down, cmove_col, hascolor, clear, clear_line, raw!, beep, enable_bracketed_paste, disable_bracketed_paste | |
import Base: size, flush, write, read, readuntil, start_reading, stop_reading | |
# wrapper around a TextTerminal that also logs all output to log | |
type LoggingTerminal <: TextTerminal | |
t::TextTerminal | |
log::IO | |
end | |
size(t::LoggingTerminal) = size(t.t) | |
writepos(t::LoggingTerminal, x, y, s::Array{Uint8,1}) = writepos(t.t, x,y,s) | |
cmove(t::LoggingTerminal, x, y) = cmove(t.t, x, y) | |
getX(t::LoggingTerminal) = getX(t.t) | |
getY(t::LoggingTerminal) = getY(t.t) | |
reseteof(t::LoggingTerminal) = reseteof(t.t) | |
cmove_up(t::LoggingTerminal, n) = cmove_up(t.t, n) | |
cmove_down(t::LoggingTerminal, n) = cmove_down(t.t, n) | |
cmove_left(t::LoggingTerminal, n) = cmove_left(t.t, n) | |
cmove_right(t::LoggingTerminal, n) = cmove_right(t.t, n) | |
cmove_line_up(t::LoggingTerminal, n) = cmove_line_up(t.t, n) | |
cmove_line_down(t::LoggingTerminal, n) = cmove_line_down(t.t, n) | |
cmove_col(t::LoggingTerminal, c) = cmove_col(t.t, c) | |
hascolor(t::LoggingTerminal) = hascolor(t.t) | |
function flush(t::LoggingTerminal) | |
flush(t.log) | |
flush(t.t) | |
end | |
clear(t::LoggingTerminal) = clear(t.t) | |
clear_line(t::LoggingTerminal, row) = clear_line(t.t, row) | |
clear_line(t::LoggingTerminal) = clear_line(t.t) | |
raw!(t::LoggingTerminal, raw::Bool) = raw!(t.t, raw) | |
beep(t::LoggingTerminal) = beep(t.t) | |
enable_bracketed_paste(t::LoggingTerminal) = enable_bracketed_paste(t.t) | |
disable_bracketed_paste(t::LoggingTerminal) = disable_bracketed_paste(t.t) | |
write{T,N}(t::LoggingTerminal, x::Array{T,N}) = begin write(t.log, x); write(t.t, x); end | |
write(t::LoggingTerminal, p::Ptr{Uint8}, x::Integer) = begin write(t.log, p, x); write(t.t, p, x); end | |
write(t::LoggingTerminal, p::Ptr{Uint8}) = begin write(t.log, p); write(t.t, p); end | |
write(t::LoggingTerminal, x::Uint8) = begin write(t.log, x); write(t.t, x); end | |
read{T,N}(t::LoggingTerminal, x::Array{T,N}) = read(t.t, x) | |
read(t::LoggingTerminal, x::Type{Uint8}) = read(t.t, x) | |
readuntil(t::LoggingTerminal, x::String) = readuntil(t.t, x) | |
readuntil(t::LoggingTerminal, x::Char) = readuntil(t.t, x) | |
readuntil(t::LoggingTerminal, x) = readuntil(t.t, x) | |
start_reading(t::LoggingTerminal) = start_reading(t.t) | |
stop_reading(t::LoggingTerminal) = stop_reading(t.t) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment