The Pedigree Project  0.1
Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
TextIO Class Reference

#include <TextIO.h>

+ Inheritance diagram for TextIO:
+ Collaboration diagram for TextIO:

Classes

struct  VgaCell
 

Public Types

enum  InputMode { Standard, Raw }
 

Public Member Functions

 TextIO (String str, size_t inode, Filesystem *pParentFS, File *pParent)
 
bool initialise (bool bClear=true)
 
void writeStr (const char *s, size_t len)
 
virtual uint64_t readBytewise (uint64_t location, uint64_t size, uintptr_t buffer, bool bCanBlock=true)
 
virtual uint64_t writeBytewise (uint64_t location, uint64_t size, uintptr_t buffer, bool bCanBlock=true)
 
virtual int select (bool bWriting=false, int timeout=0)
 
virtual void flipThread ()
 
void handleInput (InputManager::InputNotification &in)
 
void markPrimary ()
 
void unmarkPrimary ()
 
bool isPrimary () const
 
void setMode (InputMode mode)
 
InputMode getMode () const
 
- Public Member Functions inherited from File
 File ()
 
 File (const String &name, Time::Timestamp accessedTime, Time::Timestamp modifiedTime, Time::Timestamp creationTime, uintptr_t inode, class Filesystem *pFs, size_t size, File *pParent)
 
virtual ~File ()
 
virtual uint64_t read (uint64_t location, uint64_t size, uintptr_t buffer, bool bCanBlock=true) final
 
virtual uint64_t write (uint64_t location, uint64_t size, uintptr_t buffer, bool bCanBlock=true) final
 
virtual physical_uintptr_t getPhysicalPage (size_t offset)
 
virtual void returnPhysicalPage (size_t offset)
 
virtual void sync ()
 
virtual void sync (size_t offset, bool async)
 
Time::Timestamp getCreationTime ()
 
void setCreationTime (Time::Timestamp t)
 
Time::Timestamp getAccessedTime ()
 
void setAccessedTime (Time::Timestamp t)
 
Time::Timestamp getModifiedTime ()
 
void setModifiedTime (Time::Timestamp t)
 
String getName () const
 
void getName (String &s) const
 
virtual String getFullPath (bool bWithLabel=true)
 
virtual void truncate ()
 
size_t getSize ()
 
void setSize (size_t sz)
 
virtual bool isSymlink ()
 
virtual bool isDirectory ()
 
virtual bool isPipe () const
 
virtual bool isFifo () const
 
virtual bool isSocket () const
 
uintptr_t getInode () const
 
virtual void setInode (uintptr_t inode)
 
FilesystemgetFilesystem () const
 
void setFilesystem (Filesystem *pFs)
 
virtual void fileAttributeChanged ()
 
virtual void increaseRefCount (bool bIsWriter)
 
virtual void decreaseRefCount (bool bIsWriter)
 
void setPermissions (uint32_t perms)
 
uint32_t getPermissions () const
 
void setUid (size_t uid)
 
size_t getUid () const
 
void setGid (size_t gid)
 
size_t getGid () const
 
FilegetParent () const
 
void monitor (Thread *pThread, Event *pEvent)
 
void cullMonitorTargets (Thread *pThread)
 
virtual bool supports (const size_t command) const
 
virtual int command (const size_t command, void *buffer)
 
virtual size_t getBlockSize () const
 
void enableDirect ()
 
void disableDirect ()
 
virtual void preallocate (size_t expectedSize, bool zero=true)
 
virtual Fileopen ()
 

Static Public Member Functions

static void inputCallback (InputManager::InputNotification &in)
 

Private Types

enum  VgaColour {
  Black = 0, Blue = 1, Green = 2, Cyan = 3,
  Red = 4, Magenta = 5, Orange = 6, LightGrey = 7,
  DarkGrey = 8, LightBlue = 9, LightGreen = 10, LightCyan = 11,
  LightRed = 12, LightMagenta = 13, Yellow = 14, White = 15
}
 
enum  TerminalModes {
  LineFeedNewLine = 0x1, CursorKey = 0x2, AnsiVt52 = 0x4, Column = 0x8,
  Scrolling = 0x10, Screen = 0x20, Origin = 0x40, AutoWrap = 0x80,
  AutoRepeat = 0x100, Interlace = 0x200, Inverse = 0x100000, Bright = 0x200000,
  Blink = 0x400000, CharacterSetG0 = 0x1000000, CharacterSetG1 = 0x2000000
}
 

Private Member Functions

VgaColour adjustColour (int colour, bool up)
 
virtual bool isBytewise () const
 
void setColour (VgaColour *which, size_t param, bool bBright=false)
 
void doBackspace ()
 
void doLinefeed ()
 
void doCarriageReturn ()
 
void doHorizontalTab ()
 
void checkScroll ()
 
void checkWrap ()
 
void eraseSOS ()
 
void eraseEOS ()
 
void eraseEOL ()
 
void eraseSOL ()
 
void eraseLine ()
 
void eraseScreen (uint8_t character)
 
void goHome (ssize_t xmove=0, ssize_t ymove=0)
 
void clearBackbuffer ()
 
void flip (bool timer=false, bool hideState=false)
 
uint8_t translate (uint32_t codepoint)
 

Private Attributes

bool m_bInitialised
 
bool m_bControlSeq
 
bool m_bBracket
 
bool m_bParenthesis
 
bool m_bParams
 
bool m_bQuestionMark
 
ssize_t m_CursorX
 
ssize_t m_CursorY
 
ssize_t m_SavedCursorX
 
ssize_t m_SavedCursorY
 
ssize_t m_ScrollStart
 
ssize_t m_ScrollEnd
 
ssize_t m_LeftMargin
 
ssize_t m_RightMargin
 
size_t m_CurrentParam
 
size_t m_Params [MAX_TEXTIO_PARAMS]
 
int m_CurrentModes
 
VgaColour m_Fore
 
VgaColour m_Back
 
MemoryRegion m_Backbuffer
 
uint16_t * m_pFramebuffer
 
VgaCellm_pBackbuffer
 
Vgam_pVga
 
char m_TabStops [BACKBUFFER_STRIDE]
 
Buffer< char > m_OutBuffer
 
uint8_t m_G0
 
uint8_t m_G1
 
uint64_t m_NextInterval
 
bool m_bUtf8
 
uint32_t m_nCharacter
 
size_t m_nUtf8Handled
 
bool m_bActive
 
Mutex m_Lock
 
Threadm_pFlipThread
 
bool m_bOwnsConsole
 
InputMode m_InputMode
 

Static Private Attributes

static const int COLOUR_BRIGHT_ADDEND = 8
 
static const ssize_t BACKBUFFER_COLS_WIDE = 132
 
static const ssize_t BACKBUFFER_COLS_NORMAL = 80
 
static const ssize_t BACKBUFFER_ROWS = 25
 
static const ssize_t BACKBUFFER_STRIDE = BACKBUFFER_COLS_WIDE
 

Additional Inherited Members

- Protected Member Functions inherited from File
virtual uintptr_t readBlock (uint64_t location)
 
virtual void writeBlock (uint64_t location, uintptr_t addr)
 
virtual void extend (size_t newSize)
 
virtual void extend (size_t newSize, uint64_t location, uint64_t size)
 
void dataChanged ()
 
void getFilesystemLabel (HugeStaticString &s)
 
virtual void pinBlock (uint64_t location)
 
virtual void unpinBlock (uint64_t location)
 
void evict (uint64_t location)
 
void setPermissionsOnly (uint32_t perms)
 
void setUidOnly (size_t uid)
 
void setGidOnly (size_t gid)
 
- Static Protected Member Functions inherited from File
static void writeCallback (CacheConstants::CallbackCause cause, uintptr_t loc, uintptr_t page, void *meta)
 
- Protected Attributes inherited from File
String m_Name
 
Time::Timestamp m_AccessedTime
 
Time::Timestamp m_ModifiedTime
 
Time::Timestamp m_CreationTime
 
uintptr_t m_Inode
 
class Filesystemm_pFilesystem
 
size_t m_Size
 
Filem_pParent
 
size_t m_nWriters
 
size_t m_nReaders
 
size_t m_Uid
 
size_t m_Gid
 
uint32_t m_Permissions
 
HashTable< DataCacheKey, uintptr_t > m_DataCache
 
bool m_bDirect
 
Cache m_FillCache
 
Mutex m_Lock
 
List< MonitorTarget * > m_MonitorTargets
 

Detailed Description

Provides exceptionally simple VT100 emulation to the Vga class, if one exists. Note that this is NOT xterm emulation.

Definition at line 48 of file TextIO.h.

Member Enumeration Documentation

enum TextIO::TerminalModes
private
Enumerator
Inverse 

AKA: 'Negative'.

Bright 

AKA: 'Bold'.

Definition at line 85 of file TextIO.h.

Member Function Documentation

void TextIO::clearBackbuffer ( )
private

Clear backbuffer.

Definition at line 1588 of file TextIO.cc.

void TextIO::flip ( bool  timer = false,
bool  hideState = false 
)
private

Present backbuffer to the VGA instance.

Definition at line 1595 of file TextIO.cc.

References TextIO::VgaCell::hidden, and Process::m_Lock.

TextIO::InputMode TextIO::getMode ( ) const

Get the current input mode of the terminal.

Definition at line 2129 of file TextIO.cc.

bool TextIO::initialise ( bool  bClear = true)

Initialise and prepare for rendering. Clears the screen as a side-effect, unless false is passed in for bClear.

Returns
True if we can now write, false otherwise.

Definition at line 104 of file TextIO.cc.

References Machine::getVga(), Processor::information(), Process::m_Lock, and Vga::setLargestTextMode().

Referenced by DevFs::initialise(), and VirtualTerminalManager::openInactive().

+ Here is the caller graph for this function:

virtual bool TextIO::isBytewise ( ) const
inlineprivatevirtual

File subclasses can define this and return true if they require read() calls to perform actual data reads, and false if readBlock() is otherwise sufficient.

Reimplemented from File.

Definition at line 186 of file TextIO.h.

bool TextIO::isPrimary ( ) const

Determine whether this console is primary or not.

Definition at line 2119 of file TextIO.cc.

void TextIO::markPrimary ( )

Mark this console as the "primary", which means it will receive keyboard input and actively flip to the screen.

Definition at line 2102 of file TextIO.cc.

uint64_t TextIO::readBytewise ( uint64_t  location,
uint64_t  size,
uintptr_t  buffer,
bool  bCanBlock = true 
)
virtual

VFS File interface.

Reimplemented from File.

Definition at line 1661 of file TextIO.cc.

int TextIO::select ( bool  bWriting = false,
int  timeout = 0 
)
virtual

Similar to POSIX's select() function

Returns
1 if ready for reading/writing, 0 otherwise
Note
Default implementation says always ready to read/write so be sure to override if that's not right

Reimplemented from File.

Definition at line 1674 of file TextIO.cc.

void TextIO::setMode ( InputMode  mode)

Set the input mode of the terminal.

Definition at line 2124 of file TextIO.cc.

uint8_t TextIO::translate ( uint32_t  codepoint)
private

Translate given UTF32 codepoint to an ASCII character for display.

Definition at line 1704 of file TextIO.cc.

References InputManager::Key, String::Utf32ToUtf8(), and WARNING.

void TextIO::unmarkPrimary ( )

Unmark this console as the primary, ceasing its screen updates and ceasing its reception of keyboard input.

Definition at line 2114 of file TextIO.cc.

uint64_t TextIO::writeBytewise ( uint64_t  location,
uint64_t  size,
uintptr_t  buffer,
bool  bCanBlock = true 
)
virtual

Writes bytes to the file, if isBytewise() == true.

Reimplemented from File.

Definition at line 1667 of file TextIO.cc.

void TextIO::writeStr ( const char *  s,
size_t  len 
)

Write a string to the screen, handling any VT100 control sequences embedded in the string along the way.

Parameters
strThe string to write.
Todo:
Should we handle this?
Todo:
hook in to Keyboard::setLedState!
Todo:
Sanity check.
Todo:
Error out if is Utf8
Todo:
implement me!
Todo:
implement me!

Definition at line 177 of file TextIO.cc.

References Dec, ERROR, FATAL, Hex, Terminal::initialise(), Process::m_Lock, NOTICE, and WARNING.

Referenced by VirtualTerminalManager::openInactive().

+ Here is the caller graph for this function:

Member Data Documentation

bool TextIO::m_bActive
private

Are we currently active? We only become active once data is first written.

Definition at line 285 of file TextIO.h.

bool TextIO::m_bOwnsConsole
private

Does this terminal own the output to the Vga instance?

Definition at line 302 of file TextIO.h.

bool TextIO::m_bUtf8
private

Are we dealing with a UTF-8 codepoint currently?

Definition at line 273 of file TextIO.h.

uint8_t TextIO::m_G0
private

Designated character sets - simply store the character which is used to designate a character set (eg, '1', 'A').

Definition at line 267 of file TextIO.h.

Mutex TextIO::m_Lock
private

Locks writing (used for timers in particular). Avoids the case where a timer flips an in-progress operation, causing incorrect rendering.

Definition at line 292 of file TextIO.h.

uint32_t TextIO::m_nCharacter
private

Current codepoint for handling.

Definition at line 276 of file TextIO.h.

uint64_t TextIO::m_NextInterval
private

Next interval to wait for (milliseconds).

Definition at line 270 of file TextIO.h.

size_t TextIO::m_nUtf8Handled
private

Number of Utf8 bits handled so far in this sequence.

Definition at line 279 of file TextIO.h.

Buffer<char> TextIO::m_OutBuffer
private

Output buffer - data that we as the emulator want to write back to the application (eg, cursor position reports)

Definition at line 261 of file TextIO.h.

Thread* TextIO::m_pFlipThread
private

Running flip thread for things like the cursor blinking.

Definition at line 297 of file TextIO.h.


The documentation for this class was generated from the following files: