mirror of
https://github.com/autc04/Retro68.git
synced 2024-11-24 23:32:06 +00:00
Implement sequence to change the window name.
This commit is contained in:
parent
f4b2001325
commit
d40eacf12e
@ -9,7 +9,8 @@ namespace retro
|
||||
int main()
|
||||
{
|
||||
retro::InitConsole();
|
||||
std::string out = "Hello, \033[1mexternal world of \033[0m\033[3mtrue beauty and \033[4mgreatness\033[0m.\nEnter \"exit\" to quit.\n";
|
||||
std::string out = "\033]0;Hello world win\007Hello, \033[1mexternal world of \033[0m\033[3mtrue beauty and \033[4mgreatness\033[0m.\nEnter \"exit\" to quit.\n";
|
||||
//std::string out = "Hello, \033[1mexternal world of \033[0m\033[3mtrue beauty and \033[4mgreatness\033[0m.\nEnter \"exit\" to quit.\n";
|
||||
retro::Console::currentInstance->write(out.data(), out.size());
|
||||
|
||||
std::string in;
|
||||
|
@ -265,15 +265,80 @@ void Console::ScrollUp(short n)
|
||||
dirtyRect.bottom = dirtyRect.bottom > 0 ? dirtyRect.bottom - 1 : 0;
|
||||
}
|
||||
|
||||
void Console::ProcessEscSequence(char c)
|
||||
void Console::ProcessOSCseq(char c)
|
||||
{
|
||||
switch(sequenceStep)
|
||||
{
|
||||
case 0:
|
||||
if(c=='[')
|
||||
++sequenceStep;
|
||||
else
|
||||
case 1:
|
||||
if(c!='0') // The only recognized sequence is OSC 0;
|
||||
{
|
||||
OSCseq=false;
|
||||
sequenceStep=0;
|
||||
return;
|
||||
}
|
||||
++sequenceStep;
|
||||
break;
|
||||
case 2:
|
||||
if(c!=';') // The only recognized sequence is OSC 0;
|
||||
{
|
||||
OSCseq=false;
|
||||
sequenceStep=0;
|
||||
return;
|
||||
}
|
||||
++sequenceStep;
|
||||
windowName=" ";
|
||||
break;
|
||||
default:
|
||||
if(c==BEL) // The BEL character ends the sequence.
|
||||
{
|
||||
windowName[0]=windowName.length();
|
||||
SetWTitle(win, (ConstStringPtr)windowName.c_str());
|
||||
OSCseq=false;
|
||||
isProcessingEscSequence=false;
|
||||
sequenceStep=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
windowName+=c;
|
||||
++sequenceStep;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Console::ProcessEscSequence(char c)
|
||||
{
|
||||
if(sequenceStep>0 && OSCseq)
|
||||
{
|
||||
ProcessOSCseq(c);
|
||||
//sequenceStep=0;
|
||||
//isProcessingEscSequence=false;
|
||||
return;
|
||||
}
|
||||
if(sequenceStep>MAX_LEN)
|
||||
{
|
||||
// Sequence is too long!
|
||||
sequenceStep=0;
|
||||
isProcessingEscSequence=false;
|
||||
return;
|
||||
}
|
||||
|
||||
switch(sequenceStep)
|
||||
{
|
||||
case 0:
|
||||
if(c=='[') // Control Sequence Introducer
|
||||
{
|
||||
OSCseq=false;
|
||||
++sequenceStep;
|
||||
}
|
||||
else if(c==']') // Operating System Command
|
||||
{
|
||||
OSCseq=true;
|
||||
++sequenceStep;
|
||||
}
|
||||
else
|
||||
{
|
||||
isProcessingEscSequence=false;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
++sequenceStep;
|
||||
@ -305,6 +370,7 @@ void Console::ProcessEscSequence(char c)
|
||||
break;
|
||||
default:
|
||||
sequenceStep=0;
|
||||
isProcessingEscSequence=false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,9 @@
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#define BEL 7
|
||||
#define MAX_LEN 250
|
||||
|
||||
namespace retro
|
||||
{
|
||||
class Attributes
|
||||
@ -86,6 +89,10 @@ namespace retro
|
||||
void Idle();
|
||||
|
||||
bool IsEOF() const { return eof; }
|
||||
protected:
|
||||
std::string windowName;
|
||||
WindowPtr win;
|
||||
|
||||
private:
|
||||
GrafPtr consolePort = nullptr;
|
||||
Rect bounds;
|
||||
@ -94,6 +101,7 @@ namespace retro
|
||||
std::vector<AttributedChar> chars, onscreen;
|
||||
bool isProcessingEscSequence;
|
||||
int sequenceStep;
|
||||
bool OSCseq;
|
||||
|
||||
short cellSizeX;
|
||||
short cellSizeY;
|
||||
@ -118,6 +126,7 @@ namespace retro
|
||||
void DrawCells(short x1, short x2, short y, bool erase = true);
|
||||
void ScrollUp(short n = 1);
|
||||
void ProcessEscSequence(char c);
|
||||
void ProcessOSCseq(char c);
|
||||
void SetAttributes(Attributes aa);
|
||||
|
||||
void InvalidateCursor();
|
||||
|
@ -36,6 +36,7 @@ ConsoleWindow::ConsoleWindow(Rect r, ConstStr255Param title)
|
||||
{
|
||||
GrafPtr port;
|
||||
//Retro68 Improved Console
|
||||
windowName="Retro68 Console";
|
||||
win = NewWindow(NULL, &r, "\pRetro68 Console", true, 0, (WindowPtr)-1, true, 0);
|
||||
|
||||
#if !TARGET_API_MAC_CARBON
|
||||
|
@ -35,7 +35,7 @@ namespace retro
|
||||
ConsoleWindow(Rect r, ConstStr255Param title);
|
||||
~ConsoleWindow();
|
||||
private:
|
||||
WindowPtr win;
|
||||
//WindowPtr win;
|
||||
|
||||
virtual char WaitNextChar();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user