1
0
This commit is contained in:
otya128
2017-07-04 20:01:09 +09:00
parent 7e2fe1992d
commit 1c6ca86bc5
2 changed files with 76 additions and 9 deletions

View File

@@ -138,6 +138,21 @@ class Console
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 animationCursor;
FontRect[] fontTable = new FontRect[65536];
@@ -377,6 +392,24 @@ class Console
glEnable(GL_TEXTURE_2D);
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 x = 0; x < consoleWidth; x++)
{
@@ -385,6 +418,27 @@ class Console
glEnd();
glDisable(GL_TEXTURE_2D);
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 x = 0; x < consoleWidth; x++)
{

View File

@@ -739,12 +739,12 @@ class PetitComputer
bool renderprofile = false;
try
{
version(Windows)
/*version(Windows)
{
auto imm32 = LoadLibraryA("imm32.dll".toStringz);
ImmDisableIME ImmDisableIME = cast(ImmDisableIME)GetProcAddress(imm32, "ImmDisableIME".toStringz);
if(ImmDisableIME) ImmDisableIME(0);
}
}*/
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
window = SDL_CreateWindow("SMILEBASIC", SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED, 400, 240,
@@ -808,7 +808,7 @@ class PetitComputer
console.initGRPF();
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glEnable(GL_DEPTH_TEST);
version(Windows)
/*version(Windows)
{
SDL_SysWMinfo wm;
if(SDL_GetWindowWMInfo(window, &wm))
@@ -819,7 +819,7 @@ class PetitComputer
auto c = ImmAssociateContext(wm.info.win.window, null);
}
}
}
}*/
int loopcnt;
DerelictGL3.reload();
console.GRPF.createBuffer();
@@ -926,6 +926,7 @@ class PetitComputer
}
maincntRender++;
updateSticks();
bool isReturnKeyPressed;//for IM
while (SDL_PollEvent(&event))
{
switch (event.type)
@@ -984,15 +985,25 @@ class PetitComputer
}
if(key == SDLK_RETURN)
{
sendKey('\u000D');
isReturnKeyPressed = true;
}
}
break;
case SDL_TEXTINPUT:
auto text = event.text.text[0..event.text.text.indexOf('\0')].to!wstring;
foreach(wchar key; text)
case SDL_TEXTEDITING:
{
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;
case SDL_MOUSEWHEEL:
@@ -1041,6 +1052,8 @@ class PetitComputer
break;
}
}
if (isReturnKeyPressed)
sendKey('\u000D');
long delay = (1000/60) - (cast(long)SDL_GetTicks() - profile);
if(delay > 0)
SDL_Delay(cast(uint)delay);