diff --git a/source/arm11/acf.c b/source/arm11/acf.c index 6cc1b14..bd4a817 100644 --- a/source/arm11/acf.c +++ b/source/arm11/acf.c @@ -319,7 +319,7 @@ static int render_unicode(FHandle fd, int *x, unsigned width, unsigned height, u // maxwidth - 最长绘制多少个像素点,填0则忽略此参数 // utf8_line - utf8字符串 // 返回:第一个未绘制的字符的位置,如果width为0,则返回永远是NULL -const char *acf_draw(int x, int y, unsigned width, unsigned height, unsigned maxwidth, const char *utf8_line) +const char *acf_draw(int x, int y, unsigned width, unsigned height, unsigned maxwidth, uint16_t color, const char *utf8_line) { FHandle font; int linex = 0; @@ -357,7 +357,7 @@ const char *acf_draw(int x, int y, unsigned width, unsigned height, unsigned max // copy back to canvas uint16_t *frame = consoleGet()->frameBuffer; - uint16_t fg = consoleGetFgColor(); + uint16_t fg = color; for( int i=0; i < gblfont.height; ++i ) { for( int j=0; j < (int)maxwidth; ++j ) diff --git a/source/arm11/filebrowser.c b/source/arm11/filebrowser.c index a068bbe..83fa4a3 100644 --- a/source/arm11/filebrowser.c +++ b/source/arm11/filebrowser.c @@ -23,11 +23,12 @@ #include "fs.h" #include "util.h" #include "arm11/drivers/hid.h" +#include "arm11/console.h" #include "arm11/fmt.h" #include "drivers/gfx.h" #include "arm11/acf.h" -#define screenClean() ee_printf("\x1b[2J\x1b[0m") +#define screenClean() for( uint16_t *vram=consoleGet()->frameBuffer, c=CWIDTH*CHEIGHT; c-->0; vram++ ) *vram=0 // Notes on these settings: // MAX_ENT_BUF_SIZE should be big enough to hold the average file/dir name length * MAX_DIR_ENTRIES. @@ -141,8 +142,8 @@ 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 - ee_printf("\x1b[%dm", *dList -> ptrs[i] == ENT_TYPE_FILE ? 37 : 36); - acf_draw(CLEFTMARGIN, LINENO_TO_Y(i-start), CWIDTH, CHEIGHT, CLINELIMIT, &dList->ptrs[i][1] ); + const uint8_t fg = *dList -> ptrs[i] == ENT_TYPE_FILE ? 37 : 36; + acf_draw(CLEFTMARGIN, LINENO_TO_Y(i-start), CWIDTH, CHEIGHT, CLINELIMIT, consoleGetRGB565Color(fg), &dList->ptrs[i][1] ); } } @@ -172,16 +173,14 @@ Result browseFiles(const char *const basePath, char selected[512]) //ee_printf("\x1b[%lu;H\x1b[33m>%.51s", cursorPos - windowPos, &dList->ptrs[cursorPos][1]); // Draw cursor. if( oldCursorPos != cursorPos ) { - ee_printf("\x1b[%dm", *dList -> ptrs[oldCursorPos] == ENT_TYPE_FILE ? 37:36); - acf_draw( CLEFTMARGIN, LINENO_TO_Y(oldCursorPos-windowPos), CWIDTH, CHEIGHT, CLINELIMIT, &dList->ptrs[oldCursorPos][1] ); + const uint8_t fg = *dList -> ptrs[oldCursorPos] == ENT_TYPE_FILE ? 37:36 + acf_draw( CLEFTMARGIN, LINENO_TO_Y(oldCursorPos-windowPos), CWIDTH, CHEIGHT, CLINELIMIT, consoleGetRGB565Color(fg), &dList->ptrs[oldCursorPos][1] ); } - ee_printf("\x1b[33m"); - acf_draw( CLEFTMARGIN, LINENO_TO_Y(cursorPos-windowPos), CWIDTH, CHEIGHT, CLINELIMIT, &dList->ptrs[cursorPos][1] ); + acf_draw( CLEFTMARGIN, LINENO_TO_Y(cursorPos-windowPos), CWIDTH, CHEIGHT, CLINELIMIT, consoleGetRGB565Color(33), &dList->ptrs[cursorPos][1] ); } else { //ee_printf("\x1b[%lu;H\x1b[0m>%.51s", cursorPos - windowPos, ""); - ee_printf("\x1b[0m"); - acf_draw( CLEFTMARGIN, LINENO_TO_Y(cursorPos-windowPos), CWIDTH, CHEIGHT, CLINELIMIT, "" ); + acf_draw( CLEFTMARGIN, LINENO_TO_Y(cursorPos-windowPos), CWIDTH, CHEIGHT, CLINELIMIT, consoleGetRGB565Color(7), "" ); } u32 kDown;