From: Timo Korvola Date: Sun, 8 Apr 2018 19:20:00 +0000 (+0300) Subject: SDL: delete key for editing. X-Git-Url: https://scope-eye.net/git/?a=commitdiff_plain;h=e7350d23ffddc7bcb5ad4cf1513153597284b589;p=liskon_frotz.git SDL: delete key for editing. --- diff --git a/src/sdl/sf_frotz.h b/src/sdl/sf_frotz.h index d95cb22..a2c8427 100644 --- a/src/sdl/sf_frotz.h +++ b/src/sdl/sf_frotz.h @@ -253,6 +253,7 @@ void sf_FinishProfile(void); #define VK_INS 0x17 #define VK_PAGE_UP 0x18 #define VK_PAGE_DOWN 0x19 +#define VK_DEL 0x100 // for AIFF resampling diff --git a/src/sdl/sf_video.c b/src/sdl/sf_video.c index 3980da1..34f51b7 100644 --- a/src/sdl/sf_video.c +++ b/src/sdl/sf_video.c @@ -652,6 +652,7 @@ static zword goodzkey( SDL_Event *e, int allowed) numAltQ = 0; switch (e->key.keysym.sym) { case SDLK_INSERT: return (allowed ? VK_INS : 0); + case SDLK_DELETE: return (allowed ? VK_DEL : 0); case SDLK_BACKSPACE: return ZC_BACKSPACE; case SDLK_ESCAPE: return ZC_ESCAPE; case SDLK_RETURN: return ZC_RETURN; @@ -848,11 +849,20 @@ zchar os_read_line(int max, zchar *buf, int timeout, int width, int continued) case ZC_BACKSPACE: // Delete the character to the left of the cursor if (pos > 0) { - memmove(buf+pos-1,buf+pos,sizeof(zword)*(mywcslen(buf)-pos+1)); + memmove(buf + pos - 1, buf + pos, + sizeof(zword) * (mywcslen(buf) - pos + 1)); pos--; sf_DrawInput(buf,pos,ptx,pty,width,true); } continue; + case VK_DEL: + // Delete the character to the right of the cursor + if (pos < mywcslen(buf)) { + memmove(buf + pos, buf + pos + 1, + sizeof(zword) * (mywcslen(buf) - pos)); + sf_DrawInput(buf,pos,ptx,pty,width,true); + } + continue; case ZC_ESCAPE: /* Delete whole line */ pos = 0; buf[0] = '\0';