Chameleon

Chameleon Commit Details

Date:2011-09-18 16:18:21 (12 years 7 months ago)
Author:JrCs
Commit:1528
Parents: 1527
Message:Add new header file: term.h
Changes:
A/trunk/i386/libsaio/term.h
M/trunk/i386/boot2/gui.c
M/trunk/i386/boot2/gui.h
M/trunk/i386/boot2/options.c

File differences

trunk/i386/libsaio/term.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
* term.h
* Chameleon
*
* Created by JrCs on 30/08/11.
* Copyright 2011. All rights reserved.
*
*/
#ifndef __LIBSAIO_TERM_H
#define __LIBSAIO_TERM_H
#define ASCII_KEY_MASK 0x7f
#define ASCII_KEY(x) ((x & ASCII_KEY_MASK))
#define KEY_BKSP 0x0008
#define KEY_TAB 0x0009
#define KEY_ENTER 0x000d
#define KEY_ESC 0x001b
#define KEY_PRTSC 0x002a
#define KEY_LEFT 0x4b00
#define KEY_RIGHT 0x4d00
#define KEY_UP 0x4800
#define KEY_DOWN 0x5000
#define KEY_HOME 0x4700
#define KEY_END 0x4f00
#define KEY_CENTER 0x4c00
#define KEY_INS 0x5200
#define KEY_DEL 0x5300
#define KEY_PGUP 0x4900
#define KEY_PGDN 0x5100
#define KEY_F1 0x3b00
#define KEY_F2 0x3c00
#define KEY_F3 0x3d00
#define KEY_F4 0x3e00
#define KEY_F5 0x3f00
#define KEY_F6 0x4000
#define KEY_F7 0x4100
#define KEY_F8 0x4200
#define KEY_F9 0x4300
#define KEY_F10 0x4400
#define KEY_F11 0x5700
#define KEY_F12 0x5800
// Key code for input that shouldn't echoed back
#define KEY_NOECHO 0xff00
/* Bitmasks for modifier keys */
#define STATUS_RSHIFT (1 << 0)
#define STATUS_LSHIFT (1 << 1)
#define STATUS_RCTRL (1 << 2)
#define STATUS_RALT (1 << 3)
#define STATUS_SCROLL (1 << 4)
#define STATUS_NUM (1 << 5)
#define STATUS_CAPS (1 << 6)
#define STATUS_LCTRL (1 << 8)
#define STATUS_LALT (1 << 9)
#endif /* !__LIBSAIO_TERM_H */
trunk/i386/boot2/gui.c
99
1010
1111
12
1213
1314
1415
......
16041605
16051606
16061607
1607
1608
16081609
16091610
16101611
1611
1612
16121613
16131614
16141615
1615
1616
16161617
16171618
16181619
......
17621763
17631764
17641765
1765
1766
17661767
17671768
17681769
......
17841785
17851786
17861787
1787
1788
17881789
17891790
17901791
......
17961797
17971798
17981799
1799
1800
18001801
18011802
18021803
*/
#include "gui.h"
#include "term.h"
#include "appleboot.h"
#include "vers.h"
key = getchar();
if( key == kUpArrowkey )
if( key == KEY_UP )
if( currentline > 0 )
currentline--;
if( key == kDownArrowkey )
if( key == KEY_DOWN )
if( lines > ( currentline + visiblelines ) )
currentline++;
if( key == kEscapeKey || key == 'q' || key == 'Q')
if( key == KEY_ESC || key == 'q' || key == 'Q')
{
gui.infobox.draw = false;
gui.redraw = true;
switch (key)
{
case kUpArrowkey:// up arrow
case KEY_UP:// up arrow
if (infoMenuSelection > 0)
{
if(!infoMenuNativeBoot && infoMenuSelection == INFOMENU_NATIVEBOOT_END + 1)
}
break;
case kDownArrowkey:// down arrow
case KEY_DOWN:// down arrow
if (infoMenuSelection < infoMenuItemsCount - 1)
{
if(!infoMenuNativeBoot && infoMenuSelection == INFOMENU_NATIVEBOOT_START - 1)
}
break;
case kReturnKey:
case KEY_ENTER:
key = 0;
if( infoMenuSelection == MENU_SHOW_MEMORY_INFO )
showInfoBox( "Memory Info. Press q to quit.\n", getMemoryInfoString());
trunk/i386/boot2/gui.h
3838
3939
4040
41
42
43
44
45
46
47
48
49
50
51
52
5341
5442
5543
VerticalLayout= 1
};
enum {
kBackspaceKey= 0x08,
kTabKey= 0x09,
kReturnKey= '\r',
kEscapeKey= 0x1b,
kUpArrowkey= 0x4800,
kDownArrowkey= 0x5000,
kASCIIKeyMask= 0x7f,
kF5Key= 0x3f00,
kF10Key= 0x4400
};
/*
* Menu item structure.
*/
trunk/i386/boot2/options.c
2727
2828
2929
30
3031
3132
3233
......
235236
236237
237238
238
239
239240
240241
241242
242
243
243244
244245
245246
......
927928
928929
929930
930
931
931932
932933
933934
......
978979
979980
980981
981
982
982983
983984
984985
985
986
986987
987988
988989
......
993994
994995
995996
996
997
997998
998999
9991000
10001001
10011002
10021003
1003
1004
10041005
10051006
10061007
......
14601461
14611462
14621463
1463
1464
1464
1465
14651466
14661467
14671468
......
14761477
14771478
14781479
1479
1480
14801481
14811482
14821483
......
14941495
14951496
14961497
1497
1498
1499
1498
1499
1500
15001501
15011502
15021503
......
15101511
15111512
15121513
1513
1514
15141515
15151516
15161517
#include "fdisk.h"
#include "ramdisk.h"
#include "gui.h"
#include "term.h"
#include "embedded.h"
#include "pci.h"
static void updateBootArgs( int key )
{
key &= kASCIIKeyMask;
key = ASCII_KEY(key);
switch ( key )
{
case kBackspaceKey:
case KEY_BKSP:
if ( gBootArgsPtr > gBootArgs )
{
*--gBootArgsPtr = '\0';
}
switch (key) {
case kReturnKey:
case KEY_ENTER:
if (gui.menu.draw) {
key=0;
break;
gBIOSDev = menuBVR->biosdev;
break;
case kEscapeKey:
case KEY_ESC:
clearBootArgs();
break;
case kF5Key:
case KEY_F5:
// New behavior:
// Clear gBootVolume to restart the loop
// if the user enabled rescanning the optical drive.
}
break;
case kF10Key:
case KEY_F10:
gScanSingleDrive = false;
scanDisks(gBIOSDev, &bvCount);
gBootVolume = NULL;
clearBootArgs();
break;
case kTabKey:
case KEY_TAB:
// New behavior:
// Switch between text & graphic interfaces
// Only Permitted if started in graphics interface
printf("Enter two-digit hexadecimal boot device [%02x]: ", bootdevice);
do {
key = getchar();
switch (key & kASCIIKeyMask) {
case kBackspaceKey:
switch (ASCII_KEY(key)) {
case KEY_BKSP:
if (digitsI > 0) {
int x, y, t;
getCursorPositionAndType(&x, &y, &t);
}
break;
case kReturnKey:
case KEY_ENTER:
digits[digitsI] = '\0';
newbootdevice = strtol(digits, &end, 16);
if (end == digits && *end == '\0') {
break;
default:
if (isxdigit(key & kASCIIKeyMask) && digitsI < 2) {
putchar(key & kASCIIKeyMask);
digits[digitsI++] = key & kASCIIKeyMask;
if (isxdigit(ASCII_KEY(key)) && digitsI < 2) {
putchar(ASCII_KEY(key));
digits[digitsI++] = ASCII_KEY(key);
} else {
// TODO: Beep or something
}
bool promptForRescanOption(void)
{
printf("\nWould you like to enable media rescan option?\nPress ENTER to enable or any key to skip.\n");
if (getchar() == kReturnKey) {
if (getchar() == KEY_ENTER) {
return true;
} else {
return false;

Archive Download the corresponding diff file

Revision: 1528