Switch windows by tab key.

This commit is contained in:
ghosind 2021-04-13 23:56:16 +08:00
parent e809faa553
commit 5367e7fb76
3 changed files with 46 additions and 24 deletions

@ -63,7 +63,7 @@ int main(void) {
unsigned char *buf_back, buf_mouse[256], *buf_win, *buf_cons;
struct Timer *timer;
struct FIFO32 fifo;
int fifobuf[128], data;
int fifobuf[128], data, key_to = 0;
init_gdtidt();
init_pic(); // GDT/IDT完成初始化开放CPU中断
@ -183,6 +183,23 @@ int main(void) {
" ", 1);
cursor_x -= 8;
}
// Tab键
if (data == 256 + 0x0f) {
if (!key_to) {
key_to = 1;
make_window_title8(buf_win, sht_win->bxsize, "task_a", 0);
make_window_title8(buf_cons, sht_cons->bxsize, "console", 1);
} else {
key_to = 0;
make_window_title8(buf_win, sht_win->bxsize, "task_a", 1);
make_window_title8(buf_cons, sht_cons->bxsize, "console", 0);
}
sheet_refresh(sht_win, 0, 0, sht_win->bxsize, 21);
sheet_refresh(sht_cons, 0, 0, sht_cons->bxsize, 21);
}
box_fill8(sht_win->buf, sht_win->bxsize, cursor_c, cursor_x, 28,
cursor_x + 7, 43);
sheet_refresh(sht_win, cursor_x, 28, cursor_x + 8, 44);

@ -5,5 +5,6 @@
void make_window8(unsigned char *buf, int xsize, int ysize, char *title, char act);
void make_textbox8(struct Sheet *sht, int x0, int y0, int sx, int sy, int c);
void make_window_title8(unsigned char *buf, int xsize, char *title, char act);
#endif // _WINDOW_H_

@ -2,6 +2,33 @@
#include "graphic.h"
void make_window8(unsigned char *buf, int xsize, int ysize, char *title, char act) {
box_fill8(buf, xsize, COL8_C6C6C6, 0, 0, xsize - 1, 0);
box_fill8(buf, xsize, COL8_FFFFFF, 1, 1, xsize - 2, 1);
box_fill8(buf, xsize, COL8_C6C6C6, 0, 0, 0, ysize - 1);
box_fill8(buf, xsize, COL8_FFFFFF, 1, 1, 1, ysize - 2);
box_fill8(buf, xsize, COL8_848484, xsize - 2, 1, xsize - 2, ysize - 2);
box_fill8(buf, xsize, COL8_000000, xsize - 1, 0, xsize - 1, ysize - 1);
box_fill8(buf, xsize, COL8_C6C6C6, 2, 2, xsize - 3, ysize - 3);
box_fill8(buf, xsize, COL8_848484, 1, ysize - 2, xsize - 2, ysize - 2);
box_fill8(buf, xsize, COL8_000000, 0, ysize - 1, xsize - 1, ysize - 1);
make_window_title8(buf, xsize, title, act);
}
void make_textbox8(struct Sheet *sht, int x0, int y0, int sx, int sy, int c) {
int x1 = x0 + sx, y1 = y0 + sy;
box_fill8(sht->buf, sht->bxsize, COL8_848484, x0 - 2, y0 - 3, x1 + 1, y0 - 3);
box_fill8(sht->buf, sht->bxsize, COL8_848484, x0 - 3, y0 - 3, x0 - 3, y1 + 1);
box_fill8(sht->buf, sht->bxsize, COL8_FFFFFF, x0 - 3, y1 + 2, x1 + 1, y1 + 2);
box_fill8(sht->buf, sht->bxsize, COL8_FFFFFF, x1 + 2, y0 - 3, x1 + 2, y1 + 2);
box_fill8(sht->buf, sht->bxsize, COL8_000000, x0 - 1, y0 - 2, x1 + 0, y0 - 2);
box_fill8(sht->buf, sht->bxsize, COL8_000000, x0 - 2, y0 - 2, x0 - 2, y1 + 0);
box_fill8(sht->buf, sht->bxsize, COL8_C6C6C6, x0 - 2, y1 + 1, x1 + 1, y1 + 1);
box_fill8(sht->buf, sht->bxsize, COL8_C6C6C6, x1 + 1, y0 - 2, x1 + 0, y1 + 1);
box_fill8(sht->buf, sht->bxsize, c, x0 - 1, y0 - 1, x1 + 0, y1 + 0);
}
void make_window_title8(unsigned char *buf, int xsize, char *title, char act) {
static char closebtn[14][16] = {
"OOOOOOOOOOOOOOO@",
"OQQQQQQQQQQQQQ$@",
@ -27,16 +54,7 @@ void make_window8(unsigned char *buf, int xsize, int ysize, char *title, char ac
tbc = COL8_848484;
}
box_fill8(buf, xsize, COL8_C6C6C6, 0, 0, xsize - 1, 0);
box_fill8(buf, xsize, COL8_FFFFFF, 1, 1, xsize - 2, 1);
box_fill8(buf, xsize, COL8_C6C6C6, 0, 0, 0, ysize - 1);
box_fill8(buf, xsize, COL8_FFFFFF, 1, 1, 1, ysize - 2);
box_fill8(buf, xsize, COL8_848484, xsize - 2, 1, xsize - 2, ysize - 2);
box_fill8(buf, xsize, COL8_000000, xsize - 1, 0, xsize - 1, ysize - 1);
box_fill8(buf, xsize, COL8_C6C6C6, 2, 2, xsize - 3, ysize - 3);
box_fill8(buf, xsize, tbc, 3, 3, xsize - 4, 20);
box_fill8(buf, xsize, COL8_848484, 1, ysize - 2, xsize - 2, ysize - 2);
box_fill8(buf, xsize, COL8_000000, 0, ysize - 1, xsize - 1, ysize - 1);
put_fonts8_asc(buf, xsize, 24, 4, tc, title);
for (int y = 0; y < 14; y++) {
@ -60,17 +78,3 @@ void make_window8(unsigned char *buf, int xsize, int ysize, char *title, char ac
}
}
}
void make_textbox8(struct Sheet *sht, int x0, int y0, int sx, int sy, int c) {
int x1 = x0 + sx, y1 = y0 + sy;
box_fill8(sht->buf, sht->bxsize, COL8_848484, x0 - 2, y0 - 3, x1 + 1, y0 - 3);
box_fill8(sht->buf, sht->bxsize, COL8_848484, x0 - 3, y0 - 3, x0 - 3, y1 + 1);
box_fill8(sht->buf, sht->bxsize, COL8_FFFFFF, x0 - 3, y1 + 2, x1 + 1, y1 + 2);
box_fill8(sht->buf, sht->bxsize, COL8_FFFFFF, x1 + 2, y0 - 3, x1 + 2, y1 + 2);
box_fill8(sht->buf, sht->bxsize, COL8_000000, x0 - 1, y0 - 2, x1 + 0, y0 - 2);
box_fill8(sht->buf, sht->bxsize, COL8_000000, x0 - 2, y0 - 2, x0 - 2, y1 + 0);
box_fill8(sht->buf, sht->bxsize, COL8_C6C6C6, x0 - 2, y1 + 1, x1 + 1, y1 + 1);
box_fill8(sht->buf, sht->bxsize, COL8_C6C6C6, x1 + 1, y0 - 2, x1 + 0, y1 + 1);
box_fill8(sht->buf, sht->bxsize, c, x0 - 1, y0 - 1, x1 + 0, y1 + 0);
}