From da5e8092da77093bfe9b3b865b18e269df656689 Mon Sep 17 00:00:00 2001 From: root <182859762@qq.com> Date: Wed, 10 Aug 2022 14:08:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E9=80=9A=E8=BF=87=E4=BA=86?= =?UTF-8?q?=E6=97=A0console=20API=E7=9A=84=E6=98=BE=E7=A4=BA=E9=A2=9C?= =?UTF-8?q?=E8=89=B2=E7=9A=84=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/arm11/acf.h | 2 +- source/arm11/filebrowser.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/arm11/acf.h b/include/arm11/acf.h index 2d3c18f..4280090 100644 --- a/include/arm11/acf.h +++ b/include/arm11/acf.h @@ -13,7 +13,7 @@ #define ACFONT_MEM_EMPTY 5 extern int acf_set_font(const char *); -extern const char *acf_draw(int, int, unsigned, unsigned, unsigned, const char *); +extern const char *acf_draw(int, int, unsigned, unsigned, unsigned, uint16_t, const char *); #define ACF_LIT_POINT(x, y, w, h, islit) \ { \ diff --git a/source/arm11/filebrowser.c b/source/arm11/filebrowser.c index 83fa4a3..aa10ddd 100644 --- a/source/arm11/filebrowser.c +++ b/source/arm11/filebrowser.c @@ -28,7 +28,7 @@ #include "drivers/gfx.h" #include "arm11/acf.h" -#define screenClean() for( uint16_t *vram=consoleGet()->frameBuffer, c=CWIDTH*CHEIGHT; c-->0; vram++ ) *vram=0 +#define screenClean() memset(consoleGet()->frameBuffer, 0, CWIDTH*CHEIGHT*sizeof(uint16_t)) // Notes on these settings: // MAX_ENT_BUF_SIZE should be big enough to hold the average file/dir name length * MAX_DIR_ENTRIES. @@ -142,7 +142,7 @@ static void showDirList(const DirList *const dList, u32 start) // (*dList->ptrs[i] == ENT_TYPE_FILE ? "\x1b[%lu;H\x1b[37m %.51s" : "\x1b[%lu;H\x1b[36m %.51s"); //ee_printf(printStr, i - start, &dList->ptrs[i][1]); // TODO: use acf to display - const uint8_t fg = *dList -> ptrs[i] == ENT_TYPE_FILE ? 37 : 36; + const uint8_t fg = *dList -> ptrs[i] == ENT_TYPE_FILE ? 7 : 6; acf_draw(CLEFTMARGIN, LINENO_TO_Y(i-start), CWIDTH, CHEIGHT, CLINELIMIT, consoleGetRGB565Color(fg), &dList->ptrs[i][1] ); } } @@ -171,12 +171,12 @@ Result browseFiles(const char *const basePath, char selected[512]) if( dList->num > 0 ){ //ee_printf(*dList->ptrs[oldCursorPos] == ENT_TYPE_FILE ? "\x1b[%lu;H\x1b[37m %.51s" : "\x1b[%lu;H\x1b[36m %.51s", oldCursorPos - windowPos, &dList->ptrs[oldCursorPos][1]); // Clear old cursor. //ee_printf("\x1b[%lu;H\x1b[33m>%.51s", cursorPos - windowPos, &dList->ptrs[cursorPos][1]); // Draw cursor. - if( oldCursorPos != cursorPos ) + if( oldCursorPos != cursorPos && windowPos <= oldCursorPos && oldCursorPos < windowPos + SCREEN_ROWS ) { - const uint8_t fg = *dList -> ptrs[oldCursorPos] == ENT_TYPE_FILE ? 37:36 + const uint8_t fg = *dList -> ptrs[oldCursorPos] == ENT_TYPE_FILE ? 7:6; acf_draw( CLEFTMARGIN, LINENO_TO_Y(oldCursorPos-windowPos), CWIDTH, CHEIGHT, CLINELIMIT, consoleGetRGB565Color(fg), &dList->ptrs[oldCursorPos][1] ); } - acf_draw( CLEFTMARGIN, LINENO_TO_Y(cursorPos-windowPos), CWIDTH, CHEIGHT, CLINELIMIT, consoleGetRGB565Color(33), &dList->ptrs[cursorPos][1] ); + acf_draw( CLEFTMARGIN, LINENO_TO_Y(cursorPos-windowPos), CWIDTH, CHEIGHT, CLINELIMIT, consoleGetRGB565Color(3), &dList->ptrs[cursorPos][1] ); } else { //ee_printf("\x1b[%lu;H\x1b[0m>%.51s", cursorPos - windowPos, "");