Import Cardgame 0.1.15 upstream source snapshot
Original author: Pierre Sarrazin. Public-domain library and demo. Source: http://sarrazip.com/dev/cardgame-0.1.15.tar.gz Archive SHA-256: ca706dddd96fec63b829f8958c2e47485b0e1166129d45fda0b6369404c1bb54
This commit is contained in:
commit
d3a54e24ee
39 files changed
+2603
No files matched your search
@@ -0,0 +1,41 @@
|
||||
#include "cardgame.h"
|
||||
|
||||
|
||||
BOOL
|
||||
readLineFromKeyboard(KeyboardPollFunction poll,
|
||||
void *userdata,
|
||||
word ticksPerCursorPeriod,
|
||||
GetTimerFunction getTimerValue,
|
||||
char *lineBuffer, size_t bufferSize)
|
||||
{
|
||||
size_t bufIndex = 0;
|
||||
for (;;)
|
||||
{
|
||||
byte key = waitForKeyWithAnimatedCursor(poll, userdata, ticksPerCursorPeriod, getTimerValue);
|
||||
switch (key)
|
||||
{
|
||||
case '\r':
|
||||
lineBuffer[bufIndex] = '\0';
|
||||
return TRUE;
|
||||
case 3: // break
|
||||
return FALSE;
|
||||
case '\b': // backspace
|
||||
if (bufIndex > 0)
|
||||
{
|
||||
--bufIndex;
|
||||
moveCursorLeft(1);
|
||||
drawCharWithoutMovingCursor(' ');
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (key >= ' ' && key <= ']')
|
||||
{
|
||||
if (bufIndex < bufferSize - 1) // minus one, to leave space for final '\0'
|
||||
{
|
||||
lineBuffer[bufIndex++] = (char) key;
|
||||
drawChar(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user