{
tVTerm *term = gpVT_CurTerm;
- // Key Up
+ // Catch VT binds
switch( Codepoint & KEY_ACTION_MASK )
{
case KEY_ACTION_RELEASE:
case KEY_F10: VT_SetTerminal(9); return;
case KEY_F11: VT_SetTerminal(10); return;
case KEY_F12: VT_SetTerminal(11); return;
+ }
+
+ // Scrolling is only valid in text mode
+ if(gpVT_CurTerm->Mode != TERM_MODE_TEXT)
+ break;
+
+ switch(Codepoint & KEY_CODEPOINT_MASK)
+ {
// Scrolling
case KEY_PGUP:
if( gpVT_CurTerm->Flags & VT_FLAG_ALTBUF )
return ;
- if( gpVT_CurTerm->ViewPos > gpVT_CurTerm->Width )
- gpVT_CurTerm->ViewPos -= gpVT_CurTerm->Width;
- else
- gpVT_CurTerm->ViewPos = 0;
+ gpVT_CurTerm->ViewPos = MAX(
+ 0,
+ gpVT_CurTerm->ViewPos - gpVT_CurTerm->Width
+ );
return;
case KEY_PGDOWN:
if( gpVT_CurTerm->Flags & VT_FLAG_ALTBUF )
return ;
- if( gpVT_CurTerm->ViewPos < gpVT_CurTerm->Width*gpVT_CurTerm->Height*(giVT_Scrollback) )
- gpVT_CurTerm->ViewPos += gpVT_CurTerm->Width;
- else
- gpVT_CurTerm->ViewPos = gpVT_CurTerm->Width*gpVT_CurTerm->Height*(giVT_Scrollback);
+ gpVT_CurTerm->ViewPos = MIN(
+ gpVT_CurTerm->ViewPos + gpVT_CurTerm->Width,
+ gpVT_CurTerm->Width * gpVT_CurTerm->Height*giVT_Scrollback
+ );
return;
}
break;
//! Divide and Modulo 64-bit unsigned integer
extern Uint64 DivMod64U(Uint64 Num, Uint64 Den, Uint64 *Rem);
+static inline int MIN(int a, int b) { return a < b ? a : b; }
+static inline int MAX(int a, int b) { return a > b ? a : b; }
+
#include <binary_ext.h>
#include <vfs_ext.h>
#include <mutex.h>
* \brief Copy a string to a new location
* \note Copies at most `max` chars
*/
-char *strncpy(char *__str1, const char *__str2, size_t max)
+char *strncpy(char *__str1, const char *__str2, size_t __max)
{
- while(*__str2 && max-- >= 1)
+ while(*__str2 && __max-- >= 1)
*__str1++ = *__str2++;
- if(max)
+ if(__max)
*__str1 = '\0'; // Terminate String
return __str1;
}
#include <api_drv_joystick.h>\r
#include "common.h"\r
\r
-static inline int MIN(int a, int b) { return (a < b) ? a : b; }\r
-static inline int MAX(int a, int b) { return (a > b) ? a : b; }\r
-\r
// == CONSTANTS ==\r
#define NUM_AXIES 2 // X+Y\r
#define NUM_BUTTONS 5 // Left, Right, Scroll Click, Scroll Up, Scroll Down\r