raze/source/common/console/c_commandbuffer.h
Christoph Oelckers 6aa61e72b5 - backend update from GZDoom.
* cleanup on the sound init code.
* added #pragma once in several headers.
* macOS version detection overhaul.
2023-07-22 09:54:00 +02:00

64 lines
1.2 KiB
C++

#pragma once
#include <string>
#include "zstring.h"
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;
FCommandBuffer(const FCommandBuffer &o);
FString GetText() const;
size_t TextLength() const
{
return Text.length();
}
void Draw(int x, int y, int scale, bool cursor);
unsigned CalcCellSize(unsigned length);
unsigned CharsForCells(unsigned cellin, bool *overflow);
void MakeStartPosGood();
void CursorStart();
void CursorEnd();
private:
void MoveCursorLeft()
{
CursorPos--;
}
void MoveCursorRight()
{
CursorPos++;
}
public:
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();
};
extern FCommandBuffer CmdLine;