Can view large count directories, Names trimmed in viewers
This commit is contained in:
parent
0953fe31ec
commit
36e66600f5
19
helper.c
19
helper.c
@ -5,6 +5,22 @@ uint16_t *nextLine(uint16_t *p, uint16_t *b) {
|
|||||||
return (uint16_t *)(v + (160 - ((v - (uintptr_t)b) % 160)));
|
return (uint16_t *)(v + (160 - ((v - (uintptr_t)b) % 160)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void trimPath(char *path, char *buff, uint32_t maxLen) {
|
||||||
|
int pathLen = 0;
|
||||||
|
for (;path[pathLen];pathLen++);
|
||||||
|
pathLen++;
|
||||||
|
if (pathLen < maxLen) {
|
||||||
|
for(int i = 0; i < pathLen; i++)
|
||||||
|
buff[i] = path[i];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < 3; i++)
|
||||||
|
buff[i] = '.';
|
||||||
|
for (int i = 3; i < maxLen; i++) {
|
||||||
|
buff[i] = path[pathLen-maxLen+i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void V8086Int(uint8_t interrupt, union V86Regs_t *regs) {
|
void V8086Int(uint8_t interrupt, union V86Regs_t *regs) {
|
||||||
// Edit the v8086 code with the interrupt
|
// Edit the v8086 code with the interrupt
|
||||||
// Writing 4 bytes to ensure proper code
|
// Writing 4 bytes to ensure proper code
|
||||||
@ -65,7 +81,7 @@ void File83ToPath(char *src, char *path) {
|
|||||||
path[tmp] = 0;
|
path[tmp] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetFileList(DIRENT *entries, int32_t *entCount, VOLINFO *vi, DIRINFO *di) {
|
void GetFileList(DIRENT *entries, int32_t *entCount, int32_t maxEntries, VOLINFO *vi, DIRINFO *di) {
|
||||||
uint8_t *diskReadBuf = (uint8_t *)0x20000;
|
uint8_t *diskReadBuf = (uint8_t *)0x20000;
|
||||||
DIRENT de;
|
DIRENT de;
|
||||||
int32_t fileCount = 0;
|
int32_t fileCount = 0;
|
||||||
@ -77,6 +93,7 @@ void GetFileList(DIRENT *entries, int32_t *entCount, VOLINFO *vi, DIRINFO *di) {
|
|||||||
d[i] = s[i];
|
d[i] = s[i];
|
||||||
fileCount++;
|
fileCount++;
|
||||||
}
|
}
|
||||||
|
if (fileCount >= maxEntries) break;
|
||||||
}
|
}
|
||||||
*entCount = fileCount;
|
*entCount = fileCount;
|
||||||
}
|
}
|
||||||
|
3
helper.h
3
helper.h
@ -12,8 +12,9 @@ void SetVideo50Lines();
|
|||||||
void SetCursorDisabled();
|
void SetCursorDisabled();
|
||||||
|
|
||||||
uint16_t *nextLine(uint16_t *p, uint16_t *b);
|
uint16_t *nextLine(uint16_t *p, uint16_t *b);
|
||||||
|
void trimPath(char *path, char *buff, uint32_t maxLen);
|
||||||
|
|
||||||
uint32_t OpenVol(VOLINFO *vi);
|
uint32_t OpenVol(VOLINFO *vi);
|
||||||
uint32_t OpenDir(uint8_t *path, VOLINFO *vi, DIRINFO *di);
|
uint32_t OpenDir(uint8_t *path, VOLINFO *vi, DIRINFO *di);
|
||||||
void File83ToPath(char *src, char *path);
|
void File83ToPath(char *src, char *path);
|
||||||
void GetFileList(DIRENT *entries, int32_t *entCount, VOLINFO *vi, DIRINFO *di);
|
void GetFileList(DIRENT *entries, int32_t *entCount, int32_t maxEntries, VOLINFO *vi, DIRINFO *di);
|
||||||
|
16
hexedit.c
16
hexedit.c
@ -244,11 +244,15 @@ void HexEditor(uint8_t *path, VOLINFO *vi) {
|
|||||||
}
|
}
|
||||||
if (redraw) {
|
if (redraw) {
|
||||||
vga_text = (uint16_t *)0xb8000;
|
vga_text = (uint16_t *)0xb8000;
|
||||||
vga_text += printStr((char*)path, vga_text);
|
|
||||||
vga_text += printChar(fileChanged ? '*' : ' ', vga_text);
|
|
||||||
{
|
{
|
||||||
const char prnt[] = "Scroll: Up/Down PgUp/PgDown Home/End Exit: F1";
|
const char prnt[] = "Scroll: Up/Down PgUp/PgDown Home/End Exit: F1";
|
||||||
vga_text = &((uint16_t*)0xb8000)[80-sizeof(prnt)];
|
vga_text = &((uint16_t*)0xb8000)[0];
|
||||||
|
char pathBuff[22];
|
||||||
|
trimPath((char*)path, pathBuff, sizeof(pathBuff));
|
||||||
|
vga_text += printStr(pathBuff, vga_text);
|
||||||
|
vga_text += printChar(fileChanged ? '*' : ' ', vga_text);
|
||||||
|
for (;vga_text < &((uint16_t*)0xb8000)[80-sizeof(prnt)];)
|
||||||
|
vga_text += printChar(' ', vga_text);
|
||||||
vga_text += printStr((char*)prnt, vga_text);
|
vga_text += printStr((char*)prnt, vga_text);
|
||||||
}
|
}
|
||||||
vga_text = &((uint16_t*)0xb8000)[80];
|
vga_text = &((uint16_t*)0xb8000)[80];
|
||||||
@ -407,8 +411,12 @@ void HexEditor(uint8_t *path, VOLINFO *vi) {
|
|||||||
}
|
}
|
||||||
if (!fileChanged) return;
|
if (!fileChanged) return;
|
||||||
vga_text = (uint16_t*)0xb8000;
|
vga_text = (uint16_t*)0xb8000;
|
||||||
vga_text += printStr((char*)path, vga_text);
|
{
|
||||||
|
char pathBuff[23];
|
||||||
|
trimPath((char*)path, pathBuff, sizeof(pathBuff));
|
||||||
|
vga_text += printStr(pathBuff, vga_text);
|
||||||
vga_text += printChar(fileChanged ? '*' : ' ', vga_text);
|
vga_text += printChar(fileChanged ? '*' : ' ', vga_text);
|
||||||
|
}
|
||||||
vga_text += printChar(' ', vga_text);
|
vga_text += printChar(' ', vga_text);
|
||||||
vga_text += printStr("Save changes to file? (Y/N)", vga_text);
|
vga_text += printStr("Save changes to file? (Y/N)", vga_text);
|
||||||
for (;vga_text < &((uint16_t*)0xb8000)[80];vga_text++)
|
for (;vga_text < &((uint16_t*)0xb8000)[80];vga_text++)
|
||||||
|
33
kernel.c
33
kernel.c
@ -253,12 +253,13 @@ void RestoreVGA() {
|
|||||||
SetPalette();
|
SetPalette();
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t fileCount;
|
int32_t fileCount, fileOffset;
|
||||||
DIRENT *entries = (DIRENT*)0x400000;
|
DIRENT *entries = (DIRENT*)0x400000;
|
||||||
|
#define MAXDISPFILES 16
|
||||||
void PrintFileList(uint16_t *vga) {
|
void PrintFileList(uint16_t *vga) {
|
||||||
uint16_t *vga_text = &((uint16_t *)vga)[80*6+3];
|
uint16_t *vga_text = &((uint16_t *)vga)[80*6+3];
|
||||||
for (int i = 0; i < fileCount; i++) {
|
for (int i = 0; (i + fileOffset) < fileCount && i < MAXDISPFILES; i++) {
|
||||||
DIRENT *de = &entries[i];
|
DIRENT *de = &entries[i + fileOffset];
|
||||||
for (int i = 0; i < 11 && de->name[i]; i++) {
|
for (int i = 0; i < 11 && de->name[i]; i++) {
|
||||||
if (i == 8) { *(uint8_t*)vga_text = ' '; vga_text++; } // space for 8.3
|
if (i == 8) { *(uint8_t*)vga_text = ' '; vga_text++; } // space for 8.3
|
||||||
*(uint8_t *)vga_text = de->name[i];
|
*(uint8_t *)vga_text = de->name[i];
|
||||||
@ -297,7 +298,8 @@ void FileSelect() {
|
|||||||
current_path_end = 1;
|
current_path_end = 1;
|
||||||
fileCount = 5;
|
fileCount = 5;
|
||||||
uint16_t *vga_text = (uint16_t *)FileSelectScreen;
|
uint16_t *vga_text = (uint16_t *)FileSelectScreen;
|
||||||
int32_t fileHovered = 0, lastFileHovered = 0;
|
int32_t fileHovered = 0;
|
||||||
|
fileOffset = 0;
|
||||||
for (char reload = 1;;) {
|
for (char reload = 1;;) {
|
||||||
DrawScreen(vga_text);
|
DrawScreen(vga_text);
|
||||||
// Info line (4)
|
// Info line (4)
|
||||||
@ -321,15 +323,22 @@ void FileSelect() {
|
|||||||
OpenVol(&vi);
|
OpenVol(&vi);
|
||||||
current_path[current_path_end] = 0;
|
current_path[current_path_end] = 0;
|
||||||
OpenDir(current_path, &vi, &di);
|
OpenDir(current_path, &vi, &di);
|
||||||
GetFileList(entries, &fileCount, &vi, &di);
|
GetFileList(entries, &fileCount, INT32_MAX, &vi, &di);
|
||||||
reload = 0;
|
reload = 0;
|
||||||
}
|
}
|
||||||
PrintFileList(vga_text);
|
if (fileHovered >= fileCount) {
|
||||||
if (lastFileHovered != fileHovered) {
|
fileOffset = fileCount - MAXDISPFILES;
|
||||||
*(uint8_t*)&vga_text[80*(6+lastFileHovered)+2] = ' ';
|
fileHovered = fileCount - 1;
|
||||||
lastFileHovered = fileHovered;
|
|
||||||
}
|
}
|
||||||
*(uint8_t*)&vga_text[80*(6+fileHovered)+2] = '>';
|
if ((fileHovered - fileOffset) >= MAXDISPFILES)
|
||||||
|
fileOffset = fileHovered - MAXDISPFILES + 1;
|
||||||
|
else if ((fileHovered - fileOffset) < 0)
|
||||||
|
fileOffset = fileHovered;
|
||||||
|
PrintFileList(vga_text);
|
||||||
|
for (int i = 6; i < 24; i++) {
|
||||||
|
*(uint8_t*)&vga_text[80*i+2] = ' ';
|
||||||
|
}
|
||||||
|
*(uint8_t*)&vga_text[80*(6+(fileHovered-fileOffset))+2] = '>';
|
||||||
// Copy to real VGA
|
// Copy to real VGA
|
||||||
for (int i = 0; i < 80*25; i++)
|
for (int i = 0; i < 80*25; i++)
|
||||||
((uint16_t*)0xb8000)[i] = vga_text[i];
|
((uint16_t*)0xb8000)[i] = vga_text[i];
|
||||||
@ -338,7 +347,7 @@ void FileSelect() {
|
|||||||
switch (key & 0xff) { // scancode component
|
switch (key & 0xff) { // scancode component
|
||||||
case KEY_DOWN: // down
|
case KEY_DOWN: // down
|
||||||
fileHovered++;
|
fileHovered++;
|
||||||
if (fileHovered >= fileCount) fileHovered = 0;
|
if (fileHovered >= fileCount) { fileHovered = 0; fileOffset = 0; }
|
||||||
break;
|
break;
|
||||||
case KEY_UP: // up
|
case KEY_UP: // up
|
||||||
fileHovered--;
|
fileHovered--;
|
||||||
@ -392,6 +401,7 @@ void FileSelect() {
|
|||||||
current_path[current_path_end] = 0;
|
current_path[current_path_end] = 0;
|
||||||
reload = 1;
|
reload = 1;
|
||||||
fileHovered = 0;
|
fileHovered = 0;
|
||||||
|
fileOffset = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
for (int i = 0; (i + current_path_end) < sizeof(current_path); i++)
|
for (int i = 0; (i + current_path_end) < sizeof(current_path); i++)
|
||||||
@ -402,6 +412,7 @@ void FileSelect() {
|
|||||||
current_path[current_path_end] = 0;
|
current_path[current_path_end] = 0;
|
||||||
reload = 1;
|
reload = 1;
|
||||||
fileHovered = 0;
|
fileHovered = 0;
|
||||||
|
fileOffset = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case KEY_F6:
|
case KEY_F6:
|
||||||
|
7
progs.c
7
progs.c
@ -62,16 +62,17 @@ void TextViewTest(uint8_t *path, VOLINFO *vi) {
|
|||||||
vga_text = (uint16_t *)0xb8000;
|
vga_text = (uint16_t *)0xb8000;
|
||||||
for (int i = 0; i < screenSize; i++)
|
for (int i = 0; i < screenSize; i++)
|
||||||
vga_text[i] = 0x0f00;
|
vga_text[i] = 0x0f00;
|
||||||
vga_text += printStr((char*)path, vga_text);
|
char pathBuff[22];
|
||||||
|
trimPath((char*)path, pathBuff, sizeof(pathBuff));
|
||||||
|
vga_text += printStr(pathBuff, vga_text);
|
||||||
vga_text += 2;
|
vga_text += 2;
|
||||||
vga_text += printStr("Line: ", vga_text);
|
|
||||||
vga_text += printDec(currLine, vga_text);
|
vga_text += printDec(currLine, vga_text);
|
||||||
vga_text += printChar('/', vga_text);
|
vga_text += printChar('/', vga_text);
|
||||||
vga_text += printDec(lastLine, vga_text);
|
vga_text += printDec(lastLine, vga_text);
|
||||||
vga_text += printStr(" Scroll: Up/Down PgUp/PgDown Home/End", vga_text);
|
vga_text += printStr(" Scroll: Up/Down PgUp/PgDown Home/End", vga_text);
|
||||||
{
|
{
|
||||||
const char prnt[] = "Exit: E";
|
const char prnt[] = "Exit: E";
|
||||||
vga_text = &((uint16_t*)0xb8000)[80-sizeof(prnt)];
|
vga_text = &((uint16_t*)0xb8000)[80-sizeof(prnt)+1];
|
||||||
vga_text += printStr((char*)prnt, vga_text);
|
vga_text += printStr((char*)prnt, vga_text);
|
||||||
}
|
}
|
||||||
for (vga_text = &((uint16_t*)0xb8000)[84]; vga_text < &((uint16_t*)0xb8000)[screenSize]; vga_text += 80)
|
for (vga_text = &((uint16_t*)0xb8000)[84]; vga_text < &((uint16_t*)0xb8000)[screenSize]; vga_text += 80)
|
||||||
|
Loading…
Reference in New Issue
Block a user