3
(C) 2004 Hisham H. Muhammad
4
Released under the GNU GPL, see the COPYING file
5
in the source distribution for its full text.
8
#include "FunctionBar.h"
21
typedef struct FunctionBar_ {
30
/* private property */
31
char* FunctionBar_FKeys[10] = {" 1", " 2", " 3", " 4", " 5", " 6", " 7", " 8", " 9", "10"};
33
/* private property */
34
int FunctionBar_FEvents[10] = {KEY_F(1), KEY_F(2), KEY_F(3), KEY_F(4), KEY_F(5), KEY_F(6), KEY_F(7), KEY_F(8), KEY_F(9), KEY_F(10)};
36
FunctionBar* FunctionBar_new(int size, char** functions, char** keys, int* events) {
37
FunctionBar* this = malloc(sizeof(FunctionBar));
38
this->functions = functions;
42
this->events = events;
44
this->keys = FunctionBar_FKeys;
45
this->events = FunctionBar_FEvents;
46
assert(this->size == 10);
51
void FunctionBar_delete(FunctionBar* this) {
52
// These are always static data, RIGHT? >;)
53
// free(this->functions);
58
void FunctionBar_draw(FunctionBar* this, char* buffer) {
59
FunctionBar_drawAttr(this, buffer, CRT_colors[FUNCTION_BAR]);
62
void FunctionBar_drawAttr(FunctionBar* this, char* buffer, int attr) {
63
attrset(CRT_colors[FUNCTION_BAR]);
64
mvhline(LINES-1, 0, ' ', COLS);
66
for (int i = 0; i < this->size; i++) {
67
attrset(CRT_colors[FUNCTION_KEY]);
68
mvaddstr(LINES-1, x, this->keys[i]);
69
x += strlen(this->keys[i]);
70
attrset(CRT_colors[FUNCTION_BAR]);
71
mvaddstr(LINES-1, x, this->functions[i]);
72
x += strlen(this->functions[i]);
76
mvaddstr(LINES-1, x, buffer);
78
attrset(CRT_colors[RESET_COLOR]);
81
int FunctionBar_synthesizeEvent(FunctionBar* this, int pos) {
83
for (int i = 0; i < this->size; i++) {
84
x += strlen(this->keys[i]);
85
x += strlen(this->functions[i]);
87
return this->events[i];