#include "TerminalSession.h"

namespace core {
   
   TerminalSession::TerminalSession(EPoll &ePoll, TCPServer &server) : TCPSession(ePoll, server) {
   }
   
   TerminalSession::~TerminalSession() {
   }
   
   int TerminalSession::getLines() {
      struct winsize size;
      ioctl(getDescriptor(), TIOCGWINSZ, &size);		
      return size.ws_row;
   }
   
   void TerminalSession::clear() {
      out << esc << "[2J";
   }
   
   void TerminalSession::clearEOL() {
      out << esc << "[2K";
   }
   
   void TerminalSession::setCursorLocation(int x, int y) {
      out << esc << "[" << x << ";" << y << "H";
   }
   
   void TerminalSession::setColor(int color) {
      out << esc << "[" << color << "m";
   }
   
   void TerminalSession::setBackColor(int color) {
      out << esc << "[" << color << "m";
   }
   
   void TerminalSession::saveCursor() {
      out << esc << "7";
   }
   
   void TerminalSession::restoreCursor() {
      out << esc << "8";
   }
   
   void TerminalSession::NextLine(int lines) {
   }
   
   void TerminalSession::PreviousLine(int lines) {
   }  
   
   void TerminalSession::scrollArea(int start, int end) {
      out << esc << "[" << start << ";" << end << "r";
   }
   
}

