-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtckey.c
82 lines (61 loc) · 2.23 KB
/
tckey.c
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
////////////////////////////
/// TC rocks
/// Turbo Commander
////////////////////////////
#include <stdio.h>
#include <stdlib.h>
#include <string.h> // the classical ones
#include <dirent.h> // this will define path_max!!!!!!!!!!!!!!
#include <ncurses.h>
///////////////////////////////////////////////////////////
int main( int argc, char *argv[])
{
initscr();
//raw(); //ctrl+c is with raw() disabled.
keypad(stdscr, true); // keypad allows to F1,... arrows to be operational.
noecho();
// getmaxyx(stdscr, maxy, maxx);
int ch = 0 ;
int rows, cols;
getmaxyx( stdscr, rows, cols);
char userinp[PATH_MAX];
int gameover_nsc = 0;
int gameselection = 3;
while ( gameover_nsc == 0)
{
erase();
mvprintw( gameselection, 3 , "x" );
mvprintw( 0, 0 , "[Key: %d]", ch );
if ( ch == KEY_DOWN ) mvprintw( 1, 0 , "[Key: KEY_DOWN]" );
else if ( ch == KEY_UP ) mvprintw( 1, 0 , "[Key: KEY_UP]" );
else if ( ch == KEY_HOME ) mvprintw( 1, 0 , "[Key: KEY_HOME]" );
else if ( ch == KEY_END ) mvprintw( 1, 0 , "[Key: KEY_END]" );
else if ( ch == KEY_ENTER ) mvprintw( 1, 0 , "[Key: KEY_ENTER]" );
else if ( ch == KEY_EXIT ) mvprintw( 1, 0 , "[Key: KEY_EXIT]" );
else if ( ch == 9 ) mvprintw( 1, 0 , "[Key: Escape with 9]" );
else if ( ch == 27 ) mvprintw( 1, 0 , "[Key: Escape with 27]" );
else if ( ch == KEY_F(10) ) mvprintw( 1, 0 , "[Key: KEY_F(10)]" );
else if ( ch == KEY_F(11) ) mvprintw( 1, 0 , "[Key: KEY_F(11)]" );
else if ( ch == KEY_F(12) ) mvprintw( 1, 0 , "[Key: KEY_F(12)]" );
move( rows-1 , cols -1 );
ch = getch();
//if ( ch == 27) gameover_nsc = 1;
if ( ch == 'q' )
gameover_nsc = 1;
else if ( ch == 'k' )
gameselection--;
else if ( ch == 'j' )
gameselection++;
else if ( ch == KEY_UP )
gameselection--;
else if ( ch == KEY_DOWN )
gameselection++;
else if ( ch == KEY_LEFT )
gameselection--;
else if ( ch == KEY_RIGHT )
gameselection++;
}
curs_set( 1 );
endwin(); /* End curses mode */
return 0;
}