#pragma once #include #include "command.h" #include "textblob.h" using namespace std; //Everything is zero-based. class Manager; class Buffer{ TextBlob tb; Manager *manager; struct Cell{ char c; bool special; i64 linex; //position in line }; struct ScreenLine{ i64 line,part; //part: n'th screen line of the logical line `line` i64 fromx; //starting at what x into the line does this screen line have text vector cells; }; vector screen; i64 lastWidth=-1,lastHeight=-1; //excluding the gutter struct Cursorpos{ i64 line,x; }; Cursorpos cursor={0,0}; struct Screenpos{ i64 y,x; }; vector layoutLine(const string &line,i64 linenum,i64 width); void performInitialLayout(i64 width,i64 height); void renewLayout(i64 topLine,i64 topPart,i64 width,i64 height); void relayoutScreen(); void scrollUp(); Screenpos findCursorInScreen() const; void handleCommand(const Command &cmd); public: string filename; Buffer(Manager *manager); void receive(const Command &cmd); void show(i64 atx,i64 aty,i64 width,i64 height); };