From e78f2de2a2a551410bc620b46ff4c44a8606a009 Mon Sep 17 00:00:00 2001 From: makuke1234 Date: Wed, 7 Jun 2023 20:51:43 +0300 Subject: [PATCH 1/2] Add new feature --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 4be25be..5a2eae0 100644 --- a/README.md +++ b/README.md @@ -217,6 +217,7 @@ Have a look at the provided [settings file](./settings.json) to get a better und * [x] Shows more information about search result in the status * [x] Actually displays correct line number on mouse clicks * [x] Shows current line & column when typing/moving cursor around + * [ ] Shows current tab number and number of tabs on the title bar * [ ] Advanced theming support, load themes from separate files * [ ] Advanced undo/redo, choose which way to redo From a887eb91d61455ba61fdf25c1d38a8ea50480457 Mon Sep 17 00:00:00 2001 From: makuke1234 Date: Wed, 7 Jun 2023 22:37:46 +0300 Subject: [PATCH 2/2] Tab number + number of tabs --- README.md | 2 +- src/fData.c | 4 ++-- src/femto.c | 10 ++++------ src/femto.h | 4 +++- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 5a2eae0..4f3f38c 100644 --- a/README.md +++ b/README.md @@ -217,7 +217,7 @@ Have a look at the provided [settings file](./settings.json) to get a better und * [x] Shows more information about search result in the status * [x] Actually displays correct line number on mouse clicks * [x] Shows current line & column when typing/moving cursor around - * [ ] Shows current tab number and number of tabs on the title bar + * [x] Shows current tab number and number of tabs on the title bar * [ ] Advanced theming support, load themes from separate files * [ ] Advanced undo/redo, choose which way to redo diff --git a/src/fData.c b/src/fData.c index b4cc82b..b85257b 100644 --- a/src/fData.c +++ b/src/fData.c @@ -368,7 +368,7 @@ bool fData_openTab(fData_t * restrict self, const wchar * restrict fileName) fFile_close(self->files[self->fileIdx]); // Set console title - femto_setConTitle(self->files[self->fileIdx]->fileName); + femto_setConTitle(self->files[self->fileIdx]->fileName, (usize)(self->fileIdx + 1), self->filesSize); return true; } @@ -403,7 +403,7 @@ void fData_closeTab(fData_t * restrict self) // Set console title back if (self->fileIdx != -1) { - femto_setConTitle(self->files[self->fileIdx]->fileName); + femto_setConTitle(self->files[self->fileIdx]->fileName, (usize)(self->fileIdx + 1), self->filesSize); } } diff --git a/src/femto.c b/src/femto.c index 90d7317..e8046a4 100644 --- a/src/femto.c +++ b/src/femto.c @@ -647,7 +647,7 @@ static inline void s_femto_inner_saveAs(fData_t * restrict peditor, wchar * rest default: swprintf_s(tempstr, MAX_STATUS, L"Wrote %zd bytes to %s", saved, inp); // Set console title - femto_setConTitle(inp); + femto_setConTitle(inp, (usize)(peditor->fileIdx + 1), peditor->filesSize); } switch (saved) @@ -1144,7 +1144,7 @@ static inline bool s_femto_inner_kbdHandle( { pfile->data.bUpdateAll = true; fData_refreshEdit(peditor); - femto_setConTitle(pfile->fileName); + femto_setConTitle(pfile->fileName, (usize)(peditor->fileIdx + 1), peditor->filesSize); } } else if (shift) @@ -2051,13 +2051,11 @@ const wchar * femto_readBytes(HANDLE hfile, char ** restrict bytes, usize * rest return NULL; } -void femto_setConTitle(const wchar * restrict fileName) +void femto_setConTitle(const wchar * restrict fileName, usize tabNum, usize maxTabs) { fileName = (fileName == NULL) ? FEMTO_UNTITLED_NAME : fileName; wchar wndName[MAX_PATH]; - const usize fnamelen = wcslen(fileName); - memcpy(wndName, fileName, fnamelen * sizeof(wchar)); - wcscpy_s(wndName + fnamelen, MAX_PATH - fnamelen, L" - femto"); + swprintf_s(wndName, MAX_PATH, L"(%zu/%zu) %s - femto", tabNum, maxTabs, fileName); SetConsoleTitleW(wndName); } diff --git a/src/femto.h b/src/femto.h index 075d755..2813538 100644 --- a/src/femto.h +++ b/src/femto.h @@ -291,7 +291,9 @@ const wchar * femto_readBytes(HANDLE hfile, char ** restrict bytes, usize * rest * editor name on the titlebar * * @param fileName File name + * @param tabNum Currently active tab # + * @param maxTabs Total number of tabs */ -void femto_setConTitle(const wchar * restrict fileName); +void femto_setConTitle(const wchar * restrict fileName, usize tabNum, usize maxTabs); #endif