From ae3fc72e822d9ff86690650db58c105be855bab3 Mon Sep 17 00:00:00 2001 From: Keith Winstein Date: Tue, 18 Jan 2011 03:18:21 -0500 Subject: [PATCH] Initial terminal emulation sketch --- Makefile | 4 ++-- parser.cpp | 2 ++ terminal.cpp | 1 + terminal.hpp | 28 ++++++++++++++++++++++++++++ 4 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 terminal.cpp create mode 100644 terminal.hpp diff --git a/Makefile b/Makefile index 6e6a7bc..f8ecbd8 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ -source = parse.cpp parserstate.cpp parser.cpp templates.cpp -objects = parserstate.o parser.o templates.o +source = parse.cpp parserstate.cpp parser.cpp templates.cpp terminal.cpp +objects = parserstate.o parser.o templates.o terminal.o executables = parse CXX = g++ diff --git a/parser.cpp b/parser.cpp index b4e3811..f2e62f0 100644 --- a/parser.cpp +++ b/parser.cpp @@ -43,6 +43,8 @@ Parser::UTF8Parser::UTF8Parser() fprintf( stderr, "rtm requires a UTF-8 locale.\n" ); throw std::string( "rtm requires a UTF-8 locale." ); } + + assert( BUF_SIZE >= MB_CUR_MAX ); } std::vector Parser::UTF8Parser::input( char c ) diff --git a/terminal.cpp b/terminal.cpp new file mode 100644 index 0000000..9c17ba7 --- /dev/null +++ b/terminal.cpp @@ -0,0 +1 @@ +#include "terminal.hpp" diff --git a/terminal.hpp b/terminal.hpp new file mode 100644 index 0000000..65ac424 --- /dev/null +++ b/terminal.hpp @@ -0,0 +1,28 @@ +#ifndef TERMINAL_CPP +#define TERMINAL_CPP + +#include +#include "parser.hpp" + +namespace Terminal { + class Terminal { + private: + Parser::UTF8Parser parser; + + wchar_t *framebuffer; + size_t width, height; + + size_t cursor_col, cursor_row; + + public: + Terminal(); + ~Terminal(); + + + + Terminal( const Terminal & ); + Terminal &operator=( const Terminal & ); + }; +} + +#endif