2020-10-10 22:08:07 +00:00
|
|
|
#include <string>
|
|
|
|
#include "zstring.h"
|
2020-10-10 21:16:08 +00:00
|
|
|
|
|
|
|
struct FCommandBuffer
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
std::u32string Text;
|
|
|
|
unsigned CursorPos = 0;
|
|
|
|
unsigned StartPos = 0; // First character to display
|
|
|
|
unsigned CursorPosCells = 0;
|
|
|
|
unsigned StartPosCells = 0;
|
|
|
|
|
|
|
|
std::u32string YankBuffer; // Deleted text buffer
|
|
|
|
|
|
|
|
public:
|
|
|
|
bool AppendToYankBuffer = false; // Append consecutive deletes to buffer
|
|
|
|
int ConCols;
|
|
|
|
|
|
|
|
FCommandBuffer() = default;
|
|
|
|
|
2020-10-10 22:08:07 +00:00
|
|
|
FCommandBuffer(const FCommandBuffer &o);
|
|
|
|
FString GetText() const;
|
2020-10-10 21:16:08 +00:00
|
|
|
|
|
|
|
size_t TextLength() const
|
|
|
|
{
|
|
|
|
return Text.length();
|
|
|
|
}
|
|
|
|
|
2020-10-10 22:08:07 +00:00
|
|
|
void Draw(int x, int y, int scale, bool cursor);
|
|
|
|
unsigned CalcCellSize(unsigned length);
|
|
|
|
unsigned CharsForCells(unsigned cellin, bool *overflow);
|
2022-10-02 18:45:53 +00:00
|
|
|
void MakeStartPosGood();
|
2020-10-10 22:08:07 +00:00
|
|
|
void CursorStart();
|
|
|
|
void CursorEnd();
|
2020-10-10 21:16:08 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void MoveCursorLeft()
|
|
|
|
{
|
|
|
|
CursorPos--;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MoveCursorRight()
|
|
|
|
{
|
|
|
|
CursorPos++;
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2020-10-10 22:08:07 +00:00
|
|
|
void CursorLeft();
|
|
|
|
void CursorRight();
|
|
|
|
void CursorWordLeft();
|
|
|
|
void CursorWordRight();
|
|
|
|
void DeleteLeft();
|
|
|
|
void DeleteRight();
|
|
|
|
void DeleteWordLeft();
|
|
|
|
void DeleteLineLeft();
|
|
|
|
void DeleteLineRight();
|
|
|
|
void AddChar(int character);
|
|
|
|
void AddString(FString clip);
|
|
|
|
void SetString(const FString &str);
|
|
|
|
void AddYankBuffer();
|
2020-10-10 21:16:08 +00:00
|
|
|
};
|
2020-10-10 22:08:07 +00:00
|
|
|
|
|
|
|
extern FCommandBuffer CmdLine;
|