[Change] Code cleanup and doxygen.

This commit is contained in:
Allanis 2014-05-25 19:43:19 +01:00
parent 4e572b704c
commit 084ca94a93
4 changed files with 21 additions and 5 deletions

View File

@ -5,6 +5,8 @@
*/
#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.
@ -23,9 +25,9 @@ int lstd_isalpha(SDLKey k) {
}
/**
* @brief Like isalnum but for keysyms.
* @brief Check to see if a key is alphanumeric.
* @param k Key to check.
* @return 1 if is alnum.
* @return 1 if is alphanumeric.
*/
int lstd_isalnum(SDLKey k) {
int ret;
@ -43,3 +45,12 @@ int lstd_isalnum(SDLKey k) {
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;
}

View File

@ -3,4 +3,5 @@
int lstd_isalpha(SDLKey k);
int lstd_isalnum(SDLKey k);
int lstd_iscntrl(SDLKey k);

View File

@ -174,6 +174,8 @@ static void menuKeybinds_update(unsigned int wid, char* name) {
/**
* @brief Callback to set the sound level.
* @param wid Window calling the callback.
* @param str Name of the widget calling the callback.
*/
static void opt_setSFXLevel(unsigned int wid, char* str) {
double vol;
@ -183,6 +185,8 @@ static void opt_setSFXLevel(unsigned int wid, char* str) {
/**
* @brief Callback to set the music level.
* @param wid Window calling the callback.
* @param str Name of the widget calling the callback.
*/
static void opt_setMusicLevel(unsigned int wid, char* str) {
double vol;

View File

@ -1975,7 +1975,7 @@ static int toolkit_inputInput(Uint8 type, Widget* inp, SDLKey key) {
return 0;
mods = SDL_GetModState();
if(inp->dat.inp.oneline && isascii(key)) {
if(inp->dat.inp.oneline) {
/* Backspace -> delete text. */
if((key == SDLK_BACKSPACE) && (inp->dat.inp.pos > 0)) {
inp->dat.inp.input[--inp->dat.inp.pos] = '\0';
@ -1993,11 +1993,11 @@ static int toolkit_inputInput(Uint8 type, Widget* inp, SDLKey key) {
inp->dat.inp.input[inp->dat.inp.pos++] = '\n';
/* Uppder case characters. */
else if(isalpha(key) && (mods & (KMOD_LSHIFT | KMOD_RSHIFT)))
else if(lstd_isalpha(key) && (mods & (KMOD_LSHIFT | KMOD_RSHIFT)))
inp->dat.inp.input[inp->dat.inp.pos++] = toupper(key);
/* Rest. */
else if(!iscntrl(key))
else if(!lstd_iscntrl(key))
inp->dat.inp.input[inp->dat.inp.pos++] = key;
/* Didn't get a useful key. */