IME
This commit is contained in:
@@ -138,6 +138,21 @@ class Console
|
|||||||
backColors[petitcom.displaynum] = value;
|
backColors[petitcom.displaynum] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct IMEditInfo
|
||||||
|
{
|
||||||
|
wstring editingText;
|
||||||
|
int start;
|
||||||
|
int length;
|
||||||
|
}
|
||||||
|
IMEditInfo imEditInfo;
|
||||||
|
void setIMEditInfo(wstring e, int s, int l)
|
||||||
|
{
|
||||||
|
imEditInfo.editingText = e;
|
||||||
|
imEditInfo.start = s;
|
||||||
|
imEditInfo.length = l;
|
||||||
|
writefln("%s,%s,%s", e, s, l);
|
||||||
|
}
|
||||||
|
|
||||||
bool showCursor;
|
bool showCursor;
|
||||||
bool animationCursor;
|
bool animationCursor;
|
||||||
FontRect[] fontTable = new FontRect[65536];
|
FontRect[] fontTable = new FontRect[65536];
|
||||||
@@ -377,6 +392,24 @@ class Console
|
|||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
|
if (i == 0 && !imEditInfo.editingText.empty)
|
||||||
|
{
|
||||||
|
foreach (j, c; imEditInfo.editingText)
|
||||||
|
{
|
||||||
|
ConsoleCharacter cc;
|
||||||
|
cc.character = c;
|
||||||
|
cc.z = -256;
|
||||||
|
if (imEditInfo.start <= j && (imEditInfo.start + imEditInfo.length > j || imEditInfo.length == 0))
|
||||||
|
{
|
||||||
|
cc.foreColor = 10;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cc.foreColor = 1;
|
||||||
|
}
|
||||||
|
drawCharacter(j, CSRYs[0], cc);
|
||||||
|
}
|
||||||
|
}
|
||||||
for(int y = 0; y < consoleHeight; y++)
|
for(int y = 0; y < consoleHeight; y++)
|
||||||
for(int x = 0; x < consoleWidth; x++)
|
for(int x = 0; x < consoleWidth; x++)
|
||||||
{
|
{
|
||||||
@@ -385,6 +418,27 @@ class Console
|
|||||||
glEnd();
|
glEnd();
|
||||||
glDisable(GL_TEXTURE_2D);
|
glDisable(GL_TEXTURE_2D);
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
|
|
||||||
|
if (i == 0 && !imEditInfo.editingText.empty)
|
||||||
|
{
|
||||||
|
foreach (j, c; imEditInfo.editingText)
|
||||||
|
{
|
||||||
|
auto x = j, y = CSRYs[0];
|
||||||
|
auto back = consoleColorGL[15];
|
||||||
|
if (imEditInfo.start <= j && (imEditInfo.start + imEditInfo.length > j || imEditInfo.length == 0))
|
||||||
|
{
|
||||||
|
back = consoleColorGL[1];
|
||||||
|
}
|
||||||
|
if(back)
|
||||||
|
{
|
||||||
|
glColor4ubv(cast(ubyte*)&back);
|
||||||
|
glVertex3f(x * 8, y * 8 + 8, -256);
|
||||||
|
glVertex3f(x * 8, y * 8, -256);
|
||||||
|
glVertex3f(x * 8 + 8, y * 8, -256);
|
||||||
|
glVertex3f(x * 8 + 8, y * 8 + 8, -256);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
for(int y = 0; y < consoleHeight; y++)
|
for(int y = 0; y < consoleHeight; y++)
|
||||||
for(int x = 0; x < consoleWidth; x++)
|
for(int x = 0; x < consoleWidth; x++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -739,12 +739,12 @@ class PetitComputer
|
|||||||
bool renderprofile = false;
|
bool renderprofile = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
version(Windows)
|
/*version(Windows)
|
||||||
{
|
{
|
||||||
auto imm32 = LoadLibraryA("imm32.dll".toStringz);
|
auto imm32 = LoadLibraryA("imm32.dll".toStringz);
|
||||||
ImmDisableIME ImmDisableIME = cast(ImmDisableIME)GetProcAddress(imm32, "ImmDisableIME".toStringz);
|
ImmDisableIME ImmDisableIME = cast(ImmDisableIME)GetProcAddress(imm32, "ImmDisableIME".toStringz);
|
||||||
if(ImmDisableIME) ImmDisableIME(0);
|
if(ImmDisableIME) ImmDisableIME(0);
|
||||||
}
|
}*/
|
||||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
||||||
window = SDL_CreateWindow("SMILEBASIC", SDL_WINDOWPOS_UNDEFINED,
|
window = SDL_CreateWindow("SMILEBASIC", SDL_WINDOWPOS_UNDEFINED,
|
||||||
SDL_WINDOWPOS_UNDEFINED, 400, 240,
|
SDL_WINDOWPOS_UNDEFINED, 400, 240,
|
||||||
@@ -808,7 +808,7 @@ class PetitComputer
|
|||||||
console.initGRPF();
|
console.initGRPF();
|
||||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
version(Windows)
|
/*version(Windows)
|
||||||
{
|
{
|
||||||
SDL_SysWMinfo wm;
|
SDL_SysWMinfo wm;
|
||||||
if(SDL_GetWindowWMInfo(window, &wm))
|
if(SDL_GetWindowWMInfo(window, &wm))
|
||||||
@@ -819,7 +819,7 @@ class PetitComputer
|
|||||||
auto c = ImmAssociateContext(wm.info.win.window, null);
|
auto c = ImmAssociateContext(wm.info.win.window, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
int loopcnt;
|
int loopcnt;
|
||||||
DerelictGL3.reload();
|
DerelictGL3.reload();
|
||||||
console.GRPF.createBuffer();
|
console.GRPF.createBuffer();
|
||||||
@@ -926,6 +926,7 @@ class PetitComputer
|
|||||||
}
|
}
|
||||||
maincntRender++;
|
maincntRender++;
|
||||||
updateSticks();
|
updateSticks();
|
||||||
|
bool isReturnKeyPressed;//for IM
|
||||||
while (SDL_PollEvent(&event))
|
while (SDL_PollEvent(&event))
|
||||||
{
|
{
|
||||||
switch (event.type)
|
switch (event.type)
|
||||||
@@ -984,15 +985,25 @@ class PetitComputer
|
|||||||
}
|
}
|
||||||
if(key == SDLK_RETURN)
|
if(key == SDLK_RETURN)
|
||||||
{
|
{
|
||||||
sendKey('\u000D');
|
isReturnKeyPressed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_TEXTINPUT:
|
case SDL_TEXTEDITING:
|
||||||
auto text = event.text.text[0..event.text.text.indexOf('\0')].to!wstring;
|
|
||||||
foreach(wchar key; text)
|
|
||||||
{
|
{
|
||||||
sendKey(key);
|
auto text = event.edit.text[0..event.text.text.indexOf('\0')].to!wstring;
|
||||||
|
console.setIMEditInfo(text, event.edit.start, event.edit.length);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SDL_TEXTINPUT:
|
||||||
|
{
|
||||||
|
console.setIMEditInfo("", 0, 0);
|
||||||
|
auto text = event.text.text[0..event.text.text.indexOf('\0')].to!wstring;
|
||||||
|
foreach(wchar key; text)
|
||||||
|
{
|
||||||
|
sendKey(key);
|
||||||
|
}
|
||||||
|
isReturnKeyPressed = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_MOUSEWHEEL:
|
case SDL_MOUSEWHEEL:
|
||||||
@@ -1041,6 +1052,8 @@ class PetitComputer
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (isReturnKeyPressed)
|
||||||
|
sendKey('\u000D');
|
||||||
long delay = (1000/60) - (cast(long)SDL_GetTicks() - profile);
|
long delay = (1000/60) - (cast(long)SDL_GetTicks() - profile);
|
||||||
if(delay > 0)
|
if(delay > 0)
|
||||||
SDL_Delay(cast(uint)delay);
|
SDL_Delay(cast(uint)delay);
|
||||||
|
|||||||
Reference in New Issue
Block a user