mirror of
https://github.com/autc04/Retro68.git
synced 2024-11-24 23:32:06 +00:00
Slightly better strategy to convert C strings to Pascal-style ones.
This commit is contained in:
parent
9cf5c41ad7
commit
5f30a05a34
@ -12,7 +12,7 @@ int main()
|
|||||||
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 = "\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";
|
//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());
|
retro::Console::currentInstance->write(out.data(), out.size());
|
||||||
|
|
||||||
std::string in;
|
std::string in;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
@ -270,7 +270,7 @@ void Console::ProcessOSCseq(char c)
|
|||||||
switch(sequenceStep)
|
switch(sequenceStep)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
if(c!='0') // The only recognized sequence is OSC 0;
|
if(c!='0') // The only recognized sequence is OSC 0;
|
||||||
{
|
{
|
||||||
OSCseq=false;
|
OSCseq=false;
|
||||||
sequenceStep=0;
|
sequenceStep=0;
|
||||||
@ -279,7 +279,7 @@ void Console::ProcessOSCseq(char c)
|
|||||||
++sequenceStep;
|
++sequenceStep;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
if(c!=';') // The only recognized sequence is OSC 0;
|
if(c!=';') // The only recognized sequence is OSC 0;
|
||||||
{
|
{
|
||||||
OSCseq=false;
|
OSCseq=false;
|
||||||
sequenceStep=0;
|
sequenceStep=0;
|
||||||
@ -333,7 +333,7 @@ void Console::ProcessEscSequence(char c)
|
|||||||
{
|
{
|
||||||
OSCseq=true;
|
OSCseq=true;
|
||||||
++sequenceStep;
|
++sequenceStep;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
isProcessingEscSequence=false;
|
isProcessingEscSequence=false;
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include "ConsoleWindow.h"
|
#include "ConsoleWindow.h"
|
||||||
#include "Events.h"
|
#include "Events.h"
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
using namespace retro;
|
using namespace retro;
|
||||||
|
|
||||||
@ -67,9 +68,20 @@ ConsoleWindow::~ConsoleWindow()
|
|||||||
|
|
||||||
void ConsoleWindow::setWindowName(std::string newName)
|
void ConsoleWindow::setWindowName(std::string newName)
|
||||||
{
|
{
|
||||||
newName=" "+newName; // Convert into Pascal string
|
Str255 pname;
|
||||||
newName[0]=newName.length();
|
#if TARGET_API_MAC_CARBON
|
||||||
SetWTitle(win, (ConstStringPtr)newName.c_str());
|
// Carbon has the new, sane version.
|
||||||
|
c2pstrcpy(pname,newName.c_str());
|
||||||
|
#else
|
||||||
|
// It is also availble in various glue code libraries and
|
||||||
|
// in some versions of InterfaceLib, but it's confusing.
|
||||||
|
// Using the inplace variant, c2pstr, isn't much better than
|
||||||
|
// doing things by hand:
|
||||||
|
strncpy((char *)&pname[1],newName.c_str(),255);
|
||||||
|
pname[0] = newName.length();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
SetWTitle(win, pname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user