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
@ -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