formatting applied
This commit is contained in:
@@ -26,64 +26,66 @@
|
|||||||
#include "io/bootloader_flash.h"
|
#include "io/bootloader_flash.h"
|
||||||
#include "standalone_lua.h"
|
#include "standalone_lua.h"
|
||||||
|
|
||||||
class FileNameEditWindow : public Page {
|
class FileNameEditWindow : public Page
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
FileNameEditWindow(const std::string iName) :
|
FileNameEditWindow(const std::string iName) :
|
||||||
Page(ICON_RADIO_SD_MANAGER),
|
Page(ICON_RADIO_SD_MANAGER), name(std::move(iName))
|
||||||
name(std::move(iName))
|
{
|
||||||
{
|
buildBody(&body);
|
||||||
buildBody(&body);
|
buildHeader(&header);
|
||||||
buildHeader(&header);
|
};
|
||||||
};
|
|
||||||
|
|
||||||
#if defined(DEBUG_WINDOWS)
|
#if defined(DEBUG_WINDOWS)
|
||||||
std::string getName() const override
|
std::string getName() const override { return "FileNameEditWindow"; }
|
||||||
{
|
|
||||||
return "FileNameEditWindow";
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
protected:
|
protected:
|
||||||
const std::string name;
|
const std::string name;
|
||||||
|
|
||||||
void buildHeader(Window * window)
|
void buildHeader(Window *window)
|
||||||
|
{
|
||||||
|
new StaticText(window, {70, 4, 180, 30}, STR_RENAME_FILE, MENU_BGCOLOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
void buildBody(Window *window)
|
||||||
|
{
|
||||||
|
GridLayout grid(window);
|
||||||
|
grid.spacer(8);
|
||||||
|
uint8_t nameLength;
|
||||||
|
uint8_t extLength;
|
||||||
|
char *ext =
|
||||||
|
(char *)getFileExtension(name.data(), 0, 0, &nameLength, &extLength);
|
||||||
|
|
||||||
|
reusableBuffer.sdManager.ext[0] = 0;
|
||||||
|
if (ext) strncpy(reusableBuffer.sdManager.ext, ext, extLength);
|
||||||
|
|
||||||
|
nameLength -= extLength;
|
||||||
|
if (nameLength > SD_SCREEN_FILE_LENGTH) nameLength = SD_SCREEN_FILE_LENGTH;
|
||||||
|
|
||||||
|
strncpy(reusableBuffer.sdManager.originalName, name.c_str(), nameLength);
|
||||||
|
reusableBuffer.sdManager.originalName[nameLength] = 0;
|
||||||
|
|
||||||
|
auto newFileName = new TextEdit(window, grid.getSlot(),
|
||||||
|
reusableBuffer.sdManager.originalName,
|
||||||
|
SD_SCREEN_FILE_LENGTH, LcdFlags(0));
|
||||||
{
|
{
|
||||||
new StaticText(window, {70, 4, 180, 30}, STR_RENAME_FILE, MENU_BGCOLOR);
|
char *newValue = newFileName->getData();
|
||||||
|
size_t totalSize =
|
||||||
|
strlen(newValue); // sizeof(reusableBuffer.sdManager.changedName);
|
||||||
|
strncpy(reusableBuffer.sdManager.changedName, newValue, totalSize);
|
||||||
|
reusableBuffer.sdManager.changedName[totalSize] = 0;
|
||||||
|
if (extLength) {
|
||||||
|
strncpy(reusableBuffer.sdManager.changedName + totalSize,
|
||||||
|
reusableBuffer.sdManager.ext,
|
||||||
|
extLength); // totalSisze-strlen(newValue));
|
||||||
|
}
|
||||||
|
reusableBuffer.sdManager.changedName[totalSize + extLength] = 0;
|
||||||
|
f_rename((const TCHAR *)name.c_str(),
|
||||||
|
reusableBuffer.sdManager.changedName);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
void buildBody(Window * window)
|
|
||||||
{
|
|
||||||
GridLayout grid(window);
|
|
||||||
grid.spacer(8);
|
|
||||||
uint8_t nameLength;
|
|
||||||
uint8_t extLength;
|
|
||||||
char* ext = (char *)getFileExtension(name.data(), 0, 0, &nameLength, &extLength);
|
|
||||||
|
|
||||||
reusableBuffer.sdManager.ext[0] = 0;
|
|
||||||
if(ext)
|
|
||||||
strncpy(reusableBuffer.sdManager.ext, ext, extLength);
|
|
||||||
|
|
||||||
nameLength -= extLength;
|
|
||||||
if (nameLength > SD_SCREEN_FILE_LENGTH) nameLength = SD_SCREEN_FILE_LENGTH;
|
|
||||||
|
|
||||||
strncpy(reusableBuffer.sdManager.originalName, name.c_str(), nameLength);
|
|
||||||
reusableBuffer.sdManager.originalName[nameLength] = 0;
|
|
||||||
|
|
||||||
auto newFileName = new TextEdit(window, grid.getSlot(), reusableBuffer.sdManager.originalName, SD_SCREEN_FILE_LENGTH, LcdFlags(0));
|
|
||||||
{
|
|
||||||
char* newValue = newFileName->getData();
|
|
||||||
size_t totalSize = strlen(newValue);//sizeof(reusableBuffer.sdManager.changedName);
|
|
||||||
strncpy(reusableBuffer.sdManager.changedName, newValue, totalSize);
|
|
||||||
reusableBuffer.sdManager.changedName[totalSize] = 0;
|
|
||||||
if (extLength) {
|
|
||||||
strncpy(reusableBuffer.sdManager.changedName + totalSize, reusableBuffer.sdManager.ext, extLength);//totalSisze-strlen(newValue));
|
|
||||||
}
|
|
||||||
reusableBuffer.sdManager.changedName[totalSize + extLength] = 0;
|
|
||||||
f_rename((const TCHAR*)name.c_str(), reusableBuffer.sdManager.changedName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
RadioSdManagerPage::RadioSdManagerPage() :
|
RadioSdManagerPage::RadioSdManagerPage() :
|
||||||
PageTab(SD_IS_HC() ? STR_SDHC_CARD : STR_SD_CARD, ICON_RADIO_SD_MANAGER)
|
PageTab(SD_IS_HC() ? STR_SDHC_CARD : STR_SD_CARD, ICON_RADIO_SD_MANAGER)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user