Skip to content

Commit

Permalink
visual hint that a folder in library is not the bottom level
Browse files Browse the repository at this point in the history
  • Loading branch information
ravachol committed Nov 16, 2024
1 parent ba2c6c7 commit 53f1d03
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 34 deletions.
24 changes: 0 additions & 24 deletions src/directorytree.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,30 +56,6 @@ void setFullPath(FileSystemEntry *entry, const char *parentPath, const char *ent
snprintf(entry->fullPath, fullPathLength, "%s/%s", parentPath, entryName);
}

void displayTreeSimple(FileSystemEntry *root, int depth)
{
for (int i = 0; i < depth; ++i)
{
printf(" ");
}

printf("%s", root->name);
if (root->isDirectory)
{
printf(" (Directory)\n");
FileSystemEntry *child = root->children;
while (child != NULL)
{
displayTreeSimple(child, depth + 1);
child = child->next;
}
}
else
{
printf(" (File)\n");
}
}

void freeTree(FileSystemEntry *root)
{
if (root == NULL)
Expand Down
19 changes: 12 additions & 7 deletions src/player.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ int printLogo(SongData *songData, UISettings *ui)
if (ui->hideLogo && songData->metadata->artist[0] != '\0')
{
printBlankSpaces(indent);
snprintf(title, METADATA_MAX_SIZE, "%s - %s",
snprintf(title, MAXPATHLEN, "%s - %s",
songData->metadata->artist, songData->metadata->title);
}
else
Expand Down Expand Up @@ -573,7 +573,7 @@ void printLastRow(void)
}

printf("\033[K"); // clear the line

int textLength = strnlen(text, 100);

int randomNumber = getRandomNumber(1, 808);
Expand Down Expand Up @@ -1055,6 +1055,7 @@ int displayTree(FileSystemEntry *root, int depth, int maxListSize, int maxNameWi
char filename[maxNameWidth + 1];
bool foundChosen = false;
int foundCurrent = 0;
int extraIndent = 0;

UISettings *ui = &(state->uiSettings);
UIState *uis = &(state->uiState);
Expand Down Expand Up @@ -1138,7 +1139,10 @@ int displayTree(FileSystemEntry *root, int depth, int maxListSize, int maxNameWi
if (depth >= 2)
printf(" ");

printBlankSpaces(indent);
// If more than two levels deep add an extra indentation
extraIndent = (depth - 2 <= 0) ? 0 : depth;

printBlankSpaces(indent + extraIndent);

if (chosenLibRow == libIter)
{
Expand Down Expand Up @@ -1192,21 +1196,22 @@ int displayTree(FileSystemEntry *root, int depth, int maxListSize, int maxNameWi
{
dirName[0] = '\0';

snprintf(dirName, maxNameWidth + 1, "%s", root->name);
snprintf(dirName, maxNameWidth + 1 - extraIndent, "%s", root->name);

char *upperDirName = stringToUpper(dirName);

if (depth == 1)
printf("%s \n", upperDirName);
else
{
printf("%s \n", dirName);

}
free(upperDirName);
}
else
{
filename[0] = '\0';
processName(root->name, filename, maxNameWidth);
processName(root->name, filename, maxNameWidth - extraIndent);
printf(" └─%s \n", filename);

libSongIter++;
Expand Down Expand Up @@ -1242,7 +1247,7 @@ char *getLibraryFilePath(void)
}

size_t configdir_length = strnlen(configdir, MAXPATHLEN);
size_t library_file_length = strnlen(LIBRARY_FILE, MAXPATHLEN);
size_t library_file_length = strnlen(LIBRARY_FILE, sizeof(LIBRARY_FILE));

size_t filepath_length = configdir_length + 1 + library_file_length + 1;

Expand Down
13 changes: 11 additions & 2 deletions src/playerops.c
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,9 @@ void seekForward(UIState *uis)
}
}

if (isPaused())
return;

if (duration != 0.0)
{
float step = 100 / uis->numProgressBars;
Expand All @@ -580,6 +583,9 @@ void seekBack(UIState *uis)
}
}

if (isPaused())
return;

if (duration != 0.0)
{
float step = 100 / uis->numProgressBars;
Expand Down Expand Up @@ -930,12 +936,15 @@ void enqueueSongs(FileSystemEntry *entry, UIState *uis)
}
else
{
dequeueChildren(entry);
dequeueChildren(entry);

entry->isEnqueued = 0;

nextSongNeedsRebuilding = true;
}
}

if (chosenDir == NULL || entry->parent == NULL || strcmp(chosenDir->fullPath, entry->parent->fullPath) != 0)
{}
setCurrentAsChosenDir();
uis->allowChooseSongs = true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ void mapSettingsToKeys(AppSettings *settings, EventMapping *mappings)
char *getConfigFilePath(char *configdir)
{
size_t configdir_length = strnlen(configdir, MAXPATHLEN - 1);
size_t settings_file_length = strnlen(SETTINGS_FILE, MAXPATHLEN - 1);
size_t settings_file_length = strnlen(SETTINGS_FILE, sizeof(SETTINGS_FILE) - 1);

if (configdir_length + 1 + settings_file_length + 1 > MAXPATHLEN)
{
Expand Down
2 changes: 2 additions & 0 deletions src/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,8 @@ void shortenString(char *str, size_t maxLength)

void printBlankSpaces(int numSpaces)
{
if (numSpaces < 1)
return;
printf("%*s", numSpaces, " ");
}

Expand Down

0 comments on commit 53f1d03

Please sign in to comment.