[Change] Made lstd much simpler.
This commit is contained in:
parent
5304f73970
commit
d7aa607380
56
src/lstd.c
56
src/lstd.c
@ -1,56 +0,0 @@
|
||||
/**
|
||||
* @file lstd.c
|
||||
*
|
||||
* @brief Portable replacements for some functions.
|
||||
*/
|
||||
#include "lstd.h"
|
||||
|
||||
#define lstd_checkascii(k) ((k & 0xff) == k) /**< Check to see if k is in ascii area. */
|
||||
|
||||
/**
|
||||
* @brief Check to see if a key is alpha.
|
||||
* @param k Key to check.
|
||||
* @return 1 if is alpha.
|
||||
*/
|
||||
int lstd_isalpha(SDLKey k) {
|
||||
int ret;
|
||||
|
||||
ret = 0;
|
||||
|
||||
/* Alpha. */
|
||||
if((k >= SDLK_a) && (k <= SDLK_z))
|
||||
ret = 1;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check to see if a key is alphanumeric.
|
||||
* @param k Key to check.
|
||||
* @return 1 if is alphanumeric.
|
||||
*/
|
||||
int lstd_isalnum(SDLKey k) {
|
||||
int ret;
|
||||
|
||||
ret = 0;
|
||||
|
||||
/* Alpha. */
|
||||
if((k >= SDLK_a) && (k <= SDLK_z))
|
||||
ret = 1;
|
||||
|
||||
/* Number. */
|
||||
if((k >= SDLK_0) && (k <= SDLK_9))
|
||||
ret = 1;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check to see if a key is a control character.
|
||||
* @param k Key to check.
|
||||
* @param 1 if is a control character.
|
||||
*/
|
||||
int lstd_iscntrl(SDLKey k) {
|
||||
return lstd_checkascii(k) ? iscntrl(k) : 0;
|
||||
}
|
||||
|
24
src/lstd.h
24
src/lstd.h
@ -1,7 +1,23 @@
|
||||
#pragma once
|
||||
#include <SDL/SDL.h>
|
||||
#include <ctype.h>
|
||||
|
||||
int lstd_isalpha(SDLKey k);
|
||||
int lstd_isalnum(SDLKey k);
|
||||
int lstd_iscntrl(SDLKey k);
|
||||
/**
|
||||
* @brief Check to see if k is in ascii area.
|
||||
*/
|
||||
#define lstd_checkascii(k) ((k & 0xff) == k)
|
||||
|
||||
/**
|
||||
* @brief Check see if a key is alpha.
|
||||
*/
|
||||
#define lstd_isalpha(k) (lstd_checkascii(k) ? isalpha(k) : 0)
|
||||
|
||||
/**
|
||||
* @brief Check see if a key is alphanumeric.
|
||||
*/
|
||||
#define lstd_isalnum(k) (lstd_checkascii(k) ? isalnum(k) : 0)
|
||||
|
||||
/**
|
||||
* @brief Check see if a key is a control character.
|
||||
*/
|
||||
#define lstd_iscntrl(k) (lstd_checkascii(k) ? iscntrl(k) : 0)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user