Skip to content

Commit

Permalink
Merge pull request #43 from makuke1234/dev
Browse files Browse the repository at this point in the history
Tab numbers
  • Loading branch information
makuke1234 authored Jun 7, 2023
2 parents ac853e2 + a887eb9 commit 9d4eb3c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
* [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

Expand Down
4 changes: 2 additions & 2 deletions src/fData.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
}
}

Expand Down
10 changes: 4 additions & 6 deletions src/femto.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
}
4 changes: 3 additions & 1 deletion src/femto.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 9d4eb3c

Please sign in to comment.