From 67c1c44184f5b67f97f8adc298202d6242b528d1 Mon Sep 17 00:00:00 2001 From: nakst <> Date: Mon, 20 Sep 2021 08:58:29 +0100 Subject: [PATCH] show containing folder in file menu --- apps/file_manager/ui.cpp | 24 +++--- desktop/api.cpp | 93 ++++++++++++++--------- desktop/desktop.cpp | 157 +++++++++++++++++++++++++-------------- desktop/gui.cpp | 33 ++++---- desktop/os.header | 25 ++++--- desktop/styles.header | 138 +++++++++++++++++----------------- shared/common.cpp | 5 ++ shared/strings.cpp | 1 + util/api_table.ini | 3 +- util/designer/designer.c | 2 +- util/header_generator.c | 44 ++++++----- 11 files changed, 307 insertions(+), 218 deletions(-) diff --git a/apps/file_manager/ui.cpp b/apps/file_manager/ui.cpp index 435af3c..4532a6d 100644 --- a/apps/file_manager/ui.cpp +++ b/apps/file_manager/ui.cpp @@ -792,11 +792,11 @@ int ListCallback(EsElement *element, EsMessage *message) { if (fileType->openHandler) { String path = StringAllocateAndFormat("%s%s", STRFMT(instance->folder->path), STRFMT(entry->GetInternalName())); - EsApplicationStartupInformation information = {}; - information.id = fileType->openHandler; - information.filePath = path.text; - information.filePathBytes = path.bytes; - EsApplicationStart(&information); + EsApplicationStartupRequest request = {}; + request.id = fileType->openHandler; + request.filePath = path.text; + request.filePathBytes = path.bytes; + EsApplicationStart(&request); StringDestroy(&path); } else { EsDialogShowAlert(instance->window, INTERFACE_STRING(FileManagerOpenFileError), @@ -1064,20 +1064,20 @@ void InstanceCreateUI(Instance *instance) { // Load initial folder: - const EsApplicationStartupInformation *startupInformation = EsInstanceGetStartupInformation(instance); + EsApplicationStartupRequest startupRequest = EsInstanceGetStartupRequest(instance); String path; - if (startupInformation && (startupInformation->flags & ES_APPLICATION_STARTUP_MANUAL_PATH)) { - uintptr_t directoryEnd = startupInformation->filePathBytes; + if (startupRequest.flags & ES_APPLICATION_STARTUP_MANUAL_PATH) { + uintptr_t directoryEnd = startupRequest.filePathBytes; - for (uintptr_t i = 0; i < (uintptr_t) startupInformation->filePathBytes; i++) { - if (startupInformation->filePath[i] == '/') { + for (uintptr_t i = 0; i < (uintptr_t) startupRequest.filePathBytes; i++) { + if (startupRequest.filePath[i] == '/') { directoryEnd = i + 1; } } - instance->delayedFocusItem = StringAllocateAndFormat("%s", startupInformation->filePathBytes - directoryEnd, startupInformation->filePath + directoryEnd); - path = StringAllocateAndFormat("%s", directoryEnd, startupInformation->filePath); + instance->delayedFocusItem = StringAllocateAndFormat("%s", startupRequest.filePathBytes - directoryEnd, startupRequest.filePath + directoryEnd); + path = StringAllocateAndFormat("%s", directoryEnd, startupRequest.filePath); } else { path = StringAllocateAndFormat("0:/"); } diff --git a/desktop/api.cpp b/desktop/api.cpp index 52bcc15..d24e4f9 100644 --- a/desktop/api.cpp +++ b/desktop/api.cpp @@ -192,7 +192,7 @@ struct EsUndoManager { struct APIInstance { HashStore commands; - EsApplicationStartupInformation *startupInformation; + _EsApplicationStartupInformation *startupInformation; EsHandle mainWindowHandle; char *documentPath; @@ -442,40 +442,47 @@ void SystemConfigurationLoad(char *file, size_t fileBytes) { EsHeapFree(file); } -uint8_t *ApplicationStartupInformationToBuffer(const EsApplicationStartupInformation *information, size_t *dataBytes = nullptr) { - EsApplicationStartupInformation copy = *information; +uint8_t *ApplicationStartupInformationToBuffer(const _EsApplicationStartupInformation *information, size_t *dataBytes = nullptr) { + _EsApplicationStartupInformation copy = *information; if (copy.filePathBytes == -1) copy.filePathBytes = EsCStringLength(copy.filePath); - size_t bytes = 1 + sizeof(EsApplicationStartupInformation) + copy.filePathBytes; - uint8_t *buffer = (uint8_t *) EsHeapAllocate(bytes, false); - buffer[0] = DESKTOP_MSG_START_APPLICATION; - EsMemoryCopy(buffer + 1, ©, sizeof(EsApplicationStartupInformation)); - EsMemoryCopy(buffer + 1 + sizeof(EsApplicationStartupInformation), copy.filePath, copy.filePathBytes); - if (dataBytes) *dataBytes = bytes; - return buffer; + + EsBuffer buffer = { .canGrow = true }; + EsBufferWriteInt8(&buffer, DESKTOP_MSG_START_APPLICATION); + EsBufferWrite(&buffer, ©, sizeof(_EsApplicationStartupInformation)); + EsBufferWrite(&buffer, copy.filePath, copy.filePathBytes); + EsBufferWrite(&buffer, copy.containingFolder, copy.containingFolderBytes); + + if (dataBytes) *dataBytes = buffer.position; + return buffer.out; } -void EsApplicationStart(const EsApplicationStartupInformation *information) { - size_t bufferBytes; - uint8_t *buffer = ApplicationStartupInformationToBuffer(information, &bufferBytes); - MessageDesktop(buffer, bufferBytes); +_EsApplicationStartupInformation *ApplicationStartupInformationParse(const void *data, size_t dataBytes) { + EsBuffer buffer = { .in = (const uint8_t *) data, .bytes = dataBytes }; + _EsApplicationStartupInformation *startupInformation = (_EsApplicationStartupInformation *) EsBufferRead(&buffer, sizeof(_EsApplicationStartupInformation)); + startupInformation->filePath = (char *) EsHeapAllocate(startupInformation->filePathBytes, false); + EsBufferReadInto(&buffer, (char *) startupInformation->filePath, startupInformation->filePathBytes); + startupInformation->containingFolder = (char *) EsHeapAllocate(startupInformation->containingFolderBytes, false); + EsBufferReadInto(&buffer, (char *) startupInformation->containingFolder, startupInformation->containingFolderBytes); + return startupInformation; } -EsApplicationStartupInformation *ApplicationStartupInformationParse(const void *data, size_t dataBytes) { - EsApplicationStartupInformation *startupInformation = (EsApplicationStartupInformation *) data; +void EsApplicationStart(const EsApplicationStartupRequest *request) { + EsApplicationStartupRequest copy = *request; - if (sizeof(EsApplicationStartupInformation) <= dataBytes) { - dataBytes -= sizeof(EsApplicationStartupInformation); - if ((size_t) startupInformation->filePathBytes > dataBytes) goto error; - dataBytes -= startupInformation->filePathBytes; - if (dataBytes) goto error; - startupInformation->filePath = (const char *) (startupInformation + 1); - } else { - error:; - EsPrint("Warning: received corrupted startup information.\n"); - return nullptr; + if (copy.filePathBytes == -1) { + copy.filePathBytes = EsCStringLength(copy.filePath); } - return startupInformation; + EsBuffer buffer = { .canGrow = true }; + EsBufferWriteInt8(&buffer, DESKTOP_MSG_START_APPLICATION); + EsBufferWrite(&buffer, ©, sizeof(EsApplicationStartupRequest)); + EsBufferWrite(&buffer, copy.filePath, copy.filePathBytes); + + if (!buffer.error) { + MessageDesktop(buffer.out, buffer.position); + } + + EsHeapFree(buffer.out); } void EsInstanceSetClassEditor(EsInstance *_instance, const EsInstanceClassEditorSettings *settings) { @@ -752,7 +759,7 @@ EsInstance *_EsInstanceCreate(size_t bytes, EsMessage *message, const char *appl apiInstance->applicationNameBytes = applicationNameBytes; if (message && message->createInstance.data != ES_INVALID_HANDLE && message->createInstance.dataBytes > 1) { - apiInstance->startupInformation = (EsApplicationStartupInformation *) EsHeapAllocate(message->createInstance.dataBytes, false); + apiInstance->startupInformation = (_EsApplicationStartupInformation *) EsHeapAllocate(message->createInstance.dataBytes, false); if (apiInstance->startupInformation) { void *buffer = EsHeapAllocate(message->createInstance.dataBytes, false); @@ -788,9 +795,18 @@ EsInstance *_EsInstanceCreate(size_t bytes, EsMessage *message, const char *appl return instance; } -const EsApplicationStartupInformation *EsInstanceGetStartupInformation(EsInstance *_instance) { +EsApplicationStartupRequest EsInstanceGetStartupRequest(EsInstance *_instance) { APIInstance *instance = (APIInstance *) _instance->_private; - return instance->startupInformation; + EsApplicationStartupRequest request = {}; + + if (instance->startupInformation) { + request.id = instance->startupInformation->id; + request.filePath = instance->startupInformation->filePath; + request.filePathBytes = instance->startupInformation->filePathBytes; + request.flags = instance->startupInformation->flags; + } + + return request; } void EsInstanceDestroy(EsInstance *instance) { @@ -1055,14 +1071,21 @@ EsMessage *EsMessageReceive() { if (_instance) { APIInstance *instance = (APIInstance *) _instance->_private; EsHeapFree((void *) instance->startupInformation->filePath); - instance->startupInformation->filePath = buffer; - instance->startupInformation->filePathBytes = message.message.tabOperation.bytes; - EsWindowSetTitle(_instance->window, buffer, message.message.tabOperation.bytes); - } else { - EsHeapFree(buffer); + EsHeapFree((void *) instance->startupInformation->containingFolder); + EsMemoryCopy(&instance->startupInformation->filePathBytes, buffer, sizeof(ptrdiff_t)); + EsMemoryCopy(&instance->startupInformation->containingFolderBytes, buffer + sizeof(ptrdiff_t), sizeof(ptrdiff_t)); + char *filePath = (char *) EsHeapAllocate(instance->startupInformation->filePathBytes, false); + char *containingFolder = (char *) EsHeapAllocate(instance->startupInformation->containingFolderBytes, false); + EsMemoryCopy(filePath, buffer + sizeof(ptrdiff_t) * 2, instance->startupInformation->filePathBytes); + EsMemoryCopy(containingFolder, buffer + sizeof(ptrdiff_t) * 2 + instance->startupInformation->filePathBytes, + instance->startupInformation->containingFolderBytes); + instance->startupInformation->filePath = filePath; + instance->startupInformation->containingFolder = containingFolder; + EsWindowSetTitle(_instance->window, filePath, instance->startupInformation->filePathBytes); } } + EsHeapFree(buffer); EsHandleClose(message.message.tabOperation.handle); } else if (type == ES_MSG_INSTANCE_DOCUMENT_UPDATED) { EsInstance *_instance = InstanceFromWindowID(message.message.tabOperation.id); diff --git a/desktop/desktop.cpp b/desktop/desktop.cpp index 22c8bcf..6d1956d 100644 --- a/desktop/desktop.cpp +++ b/desktop/desktop.cpp @@ -220,8 +220,8 @@ struct { } desktop; int TaskBarButtonMessage(EsElement *element, EsMessage *message); -ApplicationInstance *ApplicationInstanceCreate(int64_t id, EsApplicationStartupInformation *startupInformation, ContainerWindow *container, bool hidden = false); -bool ApplicationInstanceStart(int64_t applicationID, EsApplicationStartupInformation *startupInformation, ApplicationInstance *instance); +ApplicationInstance *ApplicationInstanceCreate(int64_t id, _EsApplicationStartupInformation *startupInformation, ContainerWindow *container, bool hidden = false); +bool ApplicationInstanceStart(int64_t applicationID, _EsApplicationStartupInformation *startupInformation, ApplicationInstance *instance); void ApplicationInstanceClose(ApplicationInstance *instance); ApplicationInstance *ApplicationInstanceFindByWindowID(EsObjectID windowID, bool remove = false); void EmbeddedWindowDestroyed(EsObjectID id); @@ -1328,7 +1328,59 @@ void ApplicationInstanceCleanup(ApplicationInstance *instance) { instance->application = nullptr; } -bool ApplicationInstanceStart(int64_t applicationID, EsApplicationStartupInformation *startupInformation, ApplicationInstance *instance) { +void PathGetNameAndContainingFolder(const char *path, ptrdiff_t pathBytes, + const char **name, ptrdiff_t *nameBytes, + const char **containingFolder, ptrdiff_t *containingFolderBytes, + EsVolumeInformation *volumeInformation /* needs to be allocated outside */) { + if (pathBytes == -1) { + pathBytes = EsCStringLength(path); + } + + *name = path; + *nameBytes = pathBytes; + *containingFolderBytes = 0; + + const char *containingFolderEnd = nullptr; + + for (uintptr_t i = pathBytes; i > 0; i--) { + if (path[i - 1] == '/') { + if (!containingFolderEnd) { + containingFolderEnd = path + i - 1; + *name = path + i; + *nameBytes = pathBytes - i; + } else { + *containingFolder = path + i; + *containingFolderBytes = containingFolderEnd - *containingFolder; + } + } + } + + // TODO Get the user name of the folder from File Manager? + // Maybe more of File Manager's code needs to be shared with Desktop..? + + if (pathBytes && !(*containingFolderBytes)) { + if (EsMountPointGetVolumeInformation(path, pathBytes, volumeInformation)) { + *containingFolder = volumeInformation->label; + *containingFolderBytes = volumeInformation->labelBytes; + } + } +} + +void *OpenDocumentGetRenameMessageData(const char *path, size_t pathBytes, size_t *bytes) { + EsVolumeInformation volumeInformation; + const char *name, *containingFolder; + ptrdiff_t nameBytes, containingFolderBytes; + PathGetNameAndContainingFolder(path, pathBytes, &name, &nameBytes, &containingFolder, &containingFolderBytes, &volumeInformation); + *bytes = sizeof(ptrdiff_t) * 2 + nameBytes + containingFolderBytes; + uint8_t *data = (uint8_t *) EsHeapAllocate(*bytes, false); + EsMemoryCopy(data, &nameBytes, sizeof(ptrdiff_t)); + EsMemoryCopy(data + sizeof(ptrdiff_t), &containingFolderBytes, sizeof(ptrdiff_t)); + EsMemoryCopy(data + sizeof(ptrdiff_t) * 2, name, nameBytes); + EsMemoryCopy(data + sizeof(ptrdiff_t) * 2 + nameBytes, containingFolder, containingFolderBytes); + return data; +} + +bool ApplicationInstanceStart(int64_t applicationID, _EsApplicationStartupInformation *startupInformation, ApplicationInstance *instance) { if (desktop.inShutdown) { return false; } @@ -1349,12 +1401,12 @@ bool ApplicationInstanceStart(int64_t applicationID, EsApplicationStartupInforma } if (!application) { - EsApplicationStartupInformation s = {}; + _EsApplicationStartupInformation s = {}; s.data = CRASHED_TAB_PROGRAM_NOT_FOUND; return ApplicationInstanceStart(APPLICATION_ID_DESKTOP_CRASHED, &s, instance); } - EsApplicationStartupInformation _startupInformation = {}; + _EsApplicationStartupInformation _startupInformation = {}; if (!startupInformation) { startupInformation = &_startupInformation; @@ -1392,7 +1444,7 @@ bool ApplicationInstanceStart(int64_t applicationID, EsApplicationStartupInforma ES_FILE_READ | ES_NODE_FAIL_IF_NOT_FOUND, &executableNode); if (ES_CHECK_ERROR(error)) { - EsApplicationStartupInformation s = {}; + _EsApplicationStartupInformation s = {}; s.data = CRASHED_TAB_INVALID_EXECUTABLE; return ApplicationInstanceStart(APPLICATION_ID_DESKTOP_CRASHED, &s, instance); } @@ -1510,7 +1562,7 @@ bool ApplicationInstanceStart(int64_t applicationID, EsApplicationStartupInforma process->application = application; desktop.allApplicationProcesses.Add(process); } else { - EsApplicationStartupInformation s = {}; + _EsApplicationStartupInformation s = {}; s.data = CRASHED_TAB_INVALID_EXECUTABLE; return ApplicationInstanceStart(APPLICATION_ID_DESKTOP_CRASHED, &s, instance); } @@ -1534,18 +1586,15 @@ bool ApplicationInstanceStart(int64_t applicationID, EsApplicationStartupInforma OpenDocumentOpenReference(instance->documentID); } + EsVolumeInformation volumeInformation; + EsMessage m = { ES_MSG_INSTANCE_CREATE }; if (~startupInformation->flags & ES_APPLICATION_STARTUP_MANUAL_PATH) { - // Only tell the application the name of the file. - - for (uintptr_t i = 0; i < (size_t) startupInformation->filePathBytes; i++) { - if (startupInformation->filePath[i] == '/') { - startupInformation->filePath += i + 1; - startupInformation->filePathBytes -= i + 1; - i = 0; - } - } + PathGetNameAndContainingFolder(startupInformation->filePath, startupInformation->filePathBytes, + &startupInformation->filePath, &startupInformation->filePathBytes, + &startupInformation->containingFolder, &startupInformation->containingFolderBytes, + &volumeInformation); } // Share handles to the file and the startup information buffer. @@ -1577,7 +1626,7 @@ bool ApplicationInstanceStart(int64_t applicationID, EsApplicationStartupInforma return true; } -ApplicationInstance *ApplicationInstanceCreate(int64_t id, EsApplicationStartupInformation *startupInformation, ContainerWindow *container, bool hidden) { +ApplicationInstance *ApplicationInstanceCreate(int64_t id, _EsApplicationStartupInformation *startupInformation, ContainerWindow *container, bool hidden) { ApplicationInstance *instance = (ApplicationInstance *) EsHeapAllocate(sizeof(ApplicationInstance), true); WindowTab *tab = !hidden ? WindowTabCreate(container ?: ContainerWindowCreate(0, 0)) : nullptr; if (tab) tab->applicationInstance = instance; @@ -1743,24 +1792,30 @@ void OpenDocumentOpenReference(EsObjectID id) { document->referenceCount++; } -void OpenDocumentWithApplication(EsApplicationStartupInformation *startupInformation) { +void OpenDocumentWithApplication(EsApplicationStartupRequest *startupRequest) { bool foundDocument = false; + _EsApplicationStartupInformation startupInformation = {}; + startupInformation.id = startupRequest->id; + startupInformation.flags = startupRequest->flags; + startupInformation.filePath = startupRequest->filePath; + startupInformation.filePathBytes = startupRequest->filePathBytes; + for (uintptr_t i = 0; i < desktop.openDocuments.Count(); i++) { OpenDocument *document = &desktop.openDocuments[i]; - if (document->pathBytes == (size_t) startupInformation->filePathBytes - && 0 == EsMemoryCompare(document->path, startupInformation->filePath, document->pathBytes)) { + if (document->pathBytes == (size_t) startupInformation.filePathBytes + && 0 == EsMemoryCompare(document->path, startupInformation.filePath, document->pathBytes)) { foundDocument = true; - startupInformation->readHandle = document->readHandle; - startupInformation->documentID = document->id; + startupInformation.readHandle = document->readHandle; + startupInformation.documentID = document->id; document->referenceCount++; break; } } if (!foundDocument) { - EsFileInformation file = EsFileOpen(startupInformation->filePath, startupInformation->filePathBytes, + EsFileInformation file = EsFileOpen(startupInformation.filePath, startupInformation.filePathBytes, ES_FILE_READ_SHARED | ES_NODE_FAIL_IF_NOT_FOUND); if (file.error != ES_SUCCESS) { @@ -1769,20 +1824,20 @@ void OpenDocumentWithApplication(EsApplicationStartupInformation *startupInforma } OpenDocument document = {}; - document.path = (char *) EsHeapAllocate(startupInformation->filePathBytes, false); - document.pathBytes = startupInformation->filePathBytes; + document.path = (char *) EsHeapAllocate(startupInformation.filePathBytes, false); + document.pathBytes = startupInformation.filePathBytes; document.readHandle = file.handle; document.id = ++desktop.currentDocumentID; document.referenceCount = 1; - EsMemoryCopy(document.path, startupInformation->filePath, startupInformation->filePathBytes); + EsMemoryCopy(document.path, startupInformation.filePath, startupInformation.filePathBytes); *desktop.openDocuments.Put(&document.id) = document; - startupInformation->readHandle = document.readHandle; - startupInformation->documentID = document.id; + startupInformation.readHandle = document.readHandle; + startupInformation.documentID = document.id; } - ApplicationInstanceCreate(startupInformation->id, startupInformation, nullptr); - OpenDocumentCloseReference(startupInformation->documentID); + ApplicationInstanceCreate(startupInformation.id, &startupInformation, nullptr); + OpenDocumentCloseReference(startupInformation.documentID); } EsError TemporaryFileCreate(EsHandle *handle, char **path, size_t *pathBytes, uint32_t additionalFlags) { @@ -1857,21 +1912,13 @@ void ApplicationInstanceRequestSave(ApplicationInstance *instance, const char *n instance->documentID = document.id; { - // Tell the instance the chosen name for the document. - - uintptr_t nameOffset = 0; - - for (uintptr_t i = 0; i < nameBytes; i++) { - if (name[i] == '/') { - nameOffset = i + 1; - } - } - + // Tell the instance the chosen name and new containing folder for the document. EsMessage m = { ES_MSG_INSTANCE_DOCUMENT_RENAMED }; + void *data = OpenDocumentGetRenameMessageData(name, nameBytes, &m.tabOperation.bytes); m.tabOperation.id = instance->embeddedWindowID; - m.tabOperation.handle = EsConstantBufferCreate(name + nameOffset, nameBytes - nameOffset, instance->process->handle); - m.tabOperation.bytes = nameBytes - nameOffset; + m.tabOperation.handle = EsConstantBufferCreate(data, m.tabOperation.bytes, instance->process->handle); EsMessagePostRemote(instance->process->handle, &m); + EsHeapFree(data); } } @@ -1926,13 +1973,8 @@ void InstanceAnnouncePathMoved(InstalledApplication *fromApplication, const char return; } - uintptr_t newNameOffset = 0; - - for (uintptr_t i = 0; i < newPathBytes; i++) { - if (newPath[i] == '/') { - newNameOffset = i + 1; - } - } + size_t messageDataBytes; + void *messageData = OpenDocumentGetRenameMessageData(newPath, newPathBytes, &messageDataBytes); for (uintptr_t i = 0; i < desktop.allApplicationInstances.Length(); i++) { ApplicationInstance *instance = desktop.allApplicationInstances[i]; @@ -1943,11 +1985,13 @@ void InstanceAnnouncePathMoved(InstalledApplication *fromApplication, const char EsMessage m = { ES_MSG_INSTANCE_DOCUMENT_RENAMED }; m.tabOperation.id = instance->embeddedWindowID; - m.tabOperation.handle = EsConstantBufferCreate(newPath + newNameOffset, newPathBytes - newNameOffset, instance->process->handle); - m.tabOperation.bytes = newPathBytes - newNameOffset; + m.tabOperation.handle = EsConstantBufferCreate(messageData, messageDataBytes, instance->process->handle); + m.tabOperation.bytes = messageDataBytes; EsMessagePostRemote(instance->process->handle, &m); } + EsHeapFree(messageData); + if (fromApplication != desktop.fileManager && desktop.fileManager && desktop.fileManager->singleProcess) { char *data = (char *) EsHeapAllocate(sizeof(size_t) * 2 + oldPathBytes + newPathBytes, false); EsMemoryCopy(data + 0, &oldPathBytes, sizeof(size_t)); @@ -2218,7 +2262,7 @@ void CheckForegroundWindowResponding(EsGeneric) { // The tab is already not responding. } else { // The tab has just stopped not responding. - EsApplicationStartupInformation startupInformation = { .data = CRASHED_TAB_NOT_RESPONDING }; + _EsApplicationStartupInformation startupInformation = { .data = CRASHED_TAB_NOT_RESPONDING }; tab->notRespondingInstance = ApplicationInstanceCreate(APPLICATION_ID_DESKTOP_CRASHED, &startupInformation, tab->container, true /* hidden */); WindowTabActivate(tab, true); @@ -2361,8 +2405,11 @@ void DesktopSyscall(EsMessage *message, uint8_t *buffer, EsBuffer *pipe) { ApplicationInstance *instance = ApplicationInstanceFindByWindowID(message->desktop.windowID); if (buffer[0] == DESKTOP_MSG_START_APPLICATION) { - EsApplicationStartupInformation *information = ApplicationStartupInformationParse(buffer + 1, message->desktop.bytes - 1); - if (information) OpenDocumentWithApplication(information); + EsBuffer b = { .in = buffer + 1, .bytes = message->desktop.bytes - 1 }; + EsApplicationStartupRequest request = {}; + EsBufferReadInto(&b, &request, sizeof(EsApplicationStartupRequest)); + request.filePath = (const char *) EsBufferRead(&b, request.filePathBytes); + if (!b.error) OpenDocumentWithApplication(&request); } else if (buffer[0] == DESKTOP_MSG_CREATE_CLIPBOARD_FILE && pipe) { EsHandle processHandle = EsProcessOpen(message->desktop.processID); @@ -2582,7 +2629,7 @@ void DesktopSyscall(EsMessage *message, uint8_t *buffer, EsBuffer *pipe) { OpenDocument *document = desktop.openDocuments.Get(&instance->documentID); if (document) { - EsApplicationStartupInformation startupInformation = {}; + _EsApplicationStartupInformation startupInformation = {}; startupInformation.flags = ES_APPLICATION_STARTUP_MANUAL_PATH; startupInformation.filePath = document->path; startupInformation.filePathBytes = document->pathBytes; diff --git a/desktop/gui.cpp b/desktop/gui.cpp index 4bdf1e7..384ee25 100644 --- a/desktop/gui.cpp +++ b/desktop/gui.cpp @@ -5224,8 +5224,9 @@ EsSlider *EsSliderCreate(EsElement *parent, uint64_t flags, const EsStyle *style const EsStyle styleFileMenuDocumentInformationPanel1 = { .metrics = { - .mask = ES_THEME_METRICS_INSETS | ES_THEME_METRICS_GAP_MAJOR, + .mask = ES_THEME_METRICS_INSETS | ES_THEME_METRICS_GAP_MAJOR | ES_THEME_METRICS_PREFERRED_WIDTH, .insets = ES_RECT_4(10, 10, 5, 5), + .preferredWidth = 230, .gapMajor = 5, }, }; @@ -5322,16 +5323,16 @@ void FileMenuCreate(EsInstance *_instance, EsElement *element, EsCommand *) { { // TODO Get this icon from the file type database? - // We'll probably need Desktop to send this via EsApplicationStartupInformation and when the file is renamed. + // We'll probably need Desktop to send this via _EsApplicationStartupInformation and when the file is renamed. - EsIconDisplayCreate(panel1, ES_FLAGS_DEFAULT, 0, editorSettings->documentIconID); + EsIconDisplayCreate(panel1, ES_CELL_V_TOP, 0, editorSettings->documentIconID); EsSpacerCreate(panel1, ES_FLAGS_DEFAULT, 0, 5, 0); - EsPanel *panel2 = EsPanelCreate(panel1, ES_FLAGS_DEFAULT, &styleFileMenuDocumentInformationPanel2); + EsPanel *panel2 = EsPanelCreate(panel1, ES_CELL_H_FILL, &styleFileMenuDocumentInformationPanel2); if (!panel2) goto show; - EsPanel *switcher = EsPanelCreate(panel2, ES_PANEL_H_LEFT | ES_PANEL_SWITCHER | ES_PANEL_SWITCHER_MEASURE_LARGEST); + EsPanel *switcher = EsPanelCreate(panel2, ES_CELL_H_FILL | ES_PANEL_SWITCHER | ES_PANEL_SWITCHER_MEASURE_LARGEST); if (!switcher) goto show; - EsPanel *panel3 = EsPanelCreate(switcher, ES_PANEL_HORIZONTAL | ES_PANEL_H_LEFT, &styleFileMenuDocumentInformationPanel2); + EsPanel *panel3 = EsPanelCreate(switcher, ES_PANEL_HORIZONTAL | ES_CELL_H_FILL, &styleFileMenuDocumentInformationPanel2); if (!panel3) goto show; instance->fileMenuNameTextbox = EsTextboxCreate(switcher, ES_CELL_H_FILL | ES_TEXTBOX_EDIT_BASED, &styleFileMenuNameTextbox); @@ -5341,10 +5342,10 @@ void FileMenuCreate(EsInstance *_instance, EsElement *element, EsCommand *) { EsPanelSwitchTo(instance->fileMenuNameSwitcher, instance->fileMenuNamePanel, ES_TRANSITION_NONE); if (newDocument) { - EsTextDisplayCreate(panel3, ES_FLAGS_DEFAULT, ES_STYLE_TEXT_LABEL, + EsTextDisplayCreate(panel3, ES_CELL_H_FILL, ES_STYLE_TEXT_LABEL, editorSettings->newDocumentTitle, editorSettings->newDocumentTitleBytes); } else { - EsTextDisplayCreate(panel3, ES_FLAGS_DEFAULT, ES_STYLE_TEXT_LABEL, + EsTextDisplayCreate(panel3, ES_CELL_H_FILL, ES_STYLE_TEXT_LABEL, instance->startupInformation->filePath, instance->startupInformation->filePathBytes); } @@ -5358,10 +5359,12 @@ void FileMenuCreate(EsInstance *_instance, EsElement *element, EsCommand *) { if (!panel4) goto show; EsPanelSetBands(panel4, 2 /* columns */); - char buffer[64]; - size_t bytes; + EsTextDisplayCreate(panel4, ES_CELL_H_RIGHT, ES_STYLE_TEXT_LABEL_SECONDARY, INTERFACE_STRING(CommonFileMenuFileLocation)); + EsTextDisplayCreate(panel4, ES_CELL_H_LEFT, ES_STYLE_TEXT_LABEL, instance->startupInformation->containingFolder, + instance->startupInformation->containingFolderBytes); - bytes = EsStringFormat(buffer, sizeof(buffer), "%D", EsFileStoreGetSize(instance->fileStore)); + char buffer[64]; + size_t bytes = EsStringFormat(buffer, sizeof(buffer), "%D", EsFileStoreGetSize(instance->fileStore)); EsTextDisplayCreate(panel4, ES_CELL_H_RIGHT, ES_STYLE_TEXT_LABEL_SECONDARY, INTERFACE_STRING(CommonFileMenuFileSize)); EsTextDisplayCreate(panel4, ES_CELL_H_LEFT, ES_STYLE_TEXT_LABEL, buffer, bytes); @@ -5369,21 +5372,21 @@ void FileMenuCreate(EsInstance *_instance, EsElement *element, EsCommand *) { } } - if (instance->instanceClass == ES_INSTANCE_CLASS_EDITOR && !newDocument) { + if (instance->instanceClass == ES_INSTANCE_CLASS_EDITOR) { EsMenuAddSeparator(menu); - if (instance->commandSave.disabled) { + if (instance->commandSave.disabled && !newDocument) { EsMenuAddItem(menu, ES_ELEMENT_DISABLED, INTERFACE_STRING(CommonFileUnchanged)); } else { EsMenuAddCommand(menu, ES_FLAGS_DEFAULT, INTERFACE_STRING(CommonFileSave), &instance->commandSave); } // EsMenuAddItem(menu, newDocument ? ES_ELEMENT_DISABLED : ES_FLAGS_DEFAULT, INTERFACE_STRING(CommonFileMakeCopy)); // TODO. - EsMenuAddSeparator(menu); + // EsMenuAddSeparator(menu); // EsMenuAddItem(menu, newDocument ? ES_ELEMENT_DISABLED : ES_FLAGS_DEFAULT, INTERFACE_STRING(CommonFileShare)); // TODO. // EsMenuAddItem(menu, newDocument ? ES_ELEMENT_DISABLED : ES_FLAGS_DEFAULT, INTERFACE_STRING(CommonFileVersionHistory)); // TODO. - EsMenuAddCommand(menu, ES_FLAGS_DEFAULT, INTERFACE_STRING(CommonFileShowInFileManager), &instance->commandShowInFileManager); + EsMenuAddCommand(menu, newDocument ? ES_ELEMENT_DISABLED : ES_FLAGS_DEFAULT, INTERFACE_STRING(CommonFileShowInFileManager), &instance->commandShowInFileManager); } show: EsMenuShow(menu); diff --git a/desktop/os.header b/desktop/os.header index a9c72d7..ae2dd4e 100644 --- a/desktop/os.header +++ b/desktop/os.header @@ -1409,16 +1409,21 @@ struct EsListViewColumn { double width; }; -struct EsApplicationStartupInformation { +struct EsApplicationStartupRequest { + int64_t id; + STRING filePath; + uint32_t flags; +}; + +private struct _EsApplicationStartupInformation { int64_t id; STRING filePath; EsWindow *targetWindow; uint32_t flags; int32_t data; - - // Internal use only. EsHandle readHandle; EsObjectID documentID; + STRING containingFolder; }; struct EsINIState { @@ -1503,7 +1508,7 @@ struct EsInstanceClassEditorSettings { struct EsInstanceClassViewerSettings { }; -struct _EsNodeInformation { +private struct _EsNodeInformation { EsHandle handle; EsFileOffset fileSize; EsFileOffsetDifference directoryChildren; @@ -1840,7 +1845,7 @@ struct EsMessage { }; } -struct _EsMessageWithObject { +private struct _EsMessageWithObject { void *object; EsMessage message; }; @@ -1911,7 +1916,7 @@ function_pointer void EsWorkCallback(EsGeneric context); // System. -function void EsApplicationStart(const EsApplicationStartupInformation *information); +function void EsApplicationStart(const EsApplicationStartupRequest *request); function void EsApplicationRunTemporary(ES_INSTANCE_TYPE *instance, STRING path); function EsHandle EsTakeSystemSnapshot(int type, size_t *bufferSize); function EsInstance *_EsInstanceCreate(size_t bytes, EsMessage *message, STRING name = BLANK_STRING); @@ -2013,6 +2018,7 @@ function bool EsBufferReadInto(EsBuffer *buffer, void *destination, size_t readB function const void *EsBufferReadMany(struct EsBuffer *buffer, size_t a, size_t b); function int32_t EsBufferReadInt32Endian(EsBuffer *buffer, int32_t errorValue); function void *EsBufferWrite(EsBuffer *buffer, const void *source, size_t writeBytes); +function bool EsBufferWriteInt8(EsBuffer *buffer, int8_t value); function bool EsBufferWriteInt32Endian(EsBuffer *buffer, int32_t value); // Changes byte order if big endian. function void EsBufferFormat(EsBuffer *buffer, EsCString format, ...); // Appends. function void EsBufferFormatV(EsBuffer *buffer, EsCString format, va_list arguments); // Appends. @@ -2298,7 +2304,7 @@ function void EsInstanceDestroy(ES_INSTANCE_TYPE *instance); function void EsInstanceSetActiveUndoManager(ES_INSTANCE_TYPE *instance, EsUndoManager *manager); function void EsInstanceSetClassEditor(ES_INSTANCE_TYPE *instance, const EsInstanceClassEditorSettings *settings); function void EsInstanceSetClassViewer(ES_INSTANCE_TYPE *instance, const EsInstanceClassViewerSettings *settings); -function const EsApplicationStartupInformation *EsInstanceGetStartupInformation(ES_INSTANCE_TYPE *instance); +function EsApplicationStartupRequest EsInstanceGetStartupRequest(ES_INSTANCE_TYPE *instance); function void EsInstanceOpenComplete(EsMessage *message, bool success, STRING errorText = BLANK_STRING); function void EsInstanceSaveComplete(EsMessage *message, bool success); @@ -2376,9 +2382,8 @@ function EsElement *EsDialogShowAlert(EsWindow *window, STRING title, STRING con function void EsToolbarAddFileMenu(EsElement *element, const EsFileMenuSettings *settings = ES_NULL); -// For internal use only. -function EsHandle _EsWindowGetHandle(EsWindow *window); -function void _EsUISetFont(EsFontFamily id); +private function EsHandle _EsWindowGetHandle(EsWindow *window); +private function void _EsUISetFont(EsFontFamily id); // Buttons. diff --git a/desktop/styles.header b/desktop/styles.header index 9af4102..8383c06 100644 --- a/desktop/styles.header +++ b/desktop/styles.header @@ -1,71 +1,71 @@ -define_private ES_STYLE__TEST_STYLE (ES_STYLE_CAST(1385)) -define_private ES_STYLE_ACCESS_KEY_HINT (ES_STYLE_CAST(1221)) -define_private ES_STYLE_ANNOUNCEMENT (ES_STYLE_CAST(1511)) -define_private ES_STYLE_BREADCRUMB_BAR_CRUMB (ES_STYLE_CAST(1223)) -define_private ES_STYLE_BREADCRUMB_BAR_OVERFLOW_ICON (ES_STYLE_CAST(1225)) -define_private ES_STYLE_BREADCRUMB_BAR_PANEL (ES_STYLE_CAST(1227)) +private define ES_STYLE__TEST_STYLE (ES_STYLE_CAST(1385)) +private define ES_STYLE_ACCESS_KEY_HINT (ES_STYLE_CAST(1221)) +private define ES_STYLE_ANNOUNCEMENT (ES_STYLE_CAST(1511)) +private define ES_STYLE_BREADCRUMB_BAR_CRUMB (ES_STYLE_CAST(1223)) +private define ES_STYLE_BREADCRUMB_BAR_OVERFLOW_ICON (ES_STYLE_CAST(1225)) +private define ES_STYLE_BREADCRUMB_BAR_PANEL (ES_STYLE_CAST(1227)) define ES_STYLE_BUTTON_GROUP_CONTAINER (ES_STYLE_CAST(1229)) define ES_STYLE_BUTTON_GROUP_ITEM (ES_STYLE_CAST(1231)) define ES_STYLE_BUTTON_GROUP_SEPARATOR (ES_STYLE_CAST(1233)) -define_private ES_STYLE_CANVAS_SHADOW (ES_STYLE_CAST(1451)) -define_private ES_STYLE_CHECKBOX_NORMAL (ES_STYLE_CAST(1559)) -define_private ES_STYLE_CHECKBOX_RADIOBOX (ES_STYLE_CAST(1567)) +private define ES_STYLE_CANVAS_SHADOW (ES_STYLE_CAST(1451)) +private define ES_STYLE_CHECKBOX_NORMAL (ES_STYLE_CAST(1559)) +private define ES_STYLE_CHECKBOX_RADIOBOX (ES_STYLE_CAST(1567)) define ES_STYLE_CLEAR_BACKGROUND (ES_STYLE_CAST(1597)) -define_private ES_STYLE_COLOR_CHOSEN_POINT (ES_STYLE_CAST(1241)) -define_private ES_STYLE_COLOR_CIRCLE (ES_STYLE_CAST(1243)) -define_private ES_STYLE_COLOR_HEX_TEXTBOX (ES_STYLE_CAST(1245)) -define_private ES_STYLE_COLOR_PICKER_MAIN_PANEL (ES_STYLE_CAST(1247)) -define_private ES_STYLE_COLOR_SLIDER (ES_STYLE_CAST(1249)) -define_private ES_STYLE_CONTAINER_WINDOW (ES_STYLE_CAST(1251)) -define_private ES_STYLE_CURSOR_LOCATOR (ES_STYLE_CAST(1591)) +private define ES_STYLE_COLOR_CHOSEN_POINT (ES_STYLE_CAST(1241)) +private define ES_STYLE_COLOR_CIRCLE (ES_STYLE_CAST(1243)) +private define ES_STYLE_COLOR_HEX_TEXTBOX (ES_STYLE_CAST(1245)) +private define ES_STYLE_COLOR_PICKER_MAIN_PANEL (ES_STYLE_CAST(1247)) +private define ES_STYLE_COLOR_SLIDER (ES_STYLE_CAST(1249)) +private define ES_STYLE_CONTAINER_WINDOW (ES_STYLE_CAST(1251)) +private define ES_STYLE_CURSOR_LOCATOR (ES_STYLE_CAST(1591)) define ES_STYLE_DIALOG_BUTTON_AREA (ES_STYLE_CAST(1259)) define ES_STYLE_DIALOG_CONTENT (ES_STYLE_CAST(1261)) define ES_STYLE_DIALOG_HEADING (ES_STYLE_CAST(1263)) -define_private ES_STYLE_DOUBLE_CLICK_TEST (ES_STYLE_CAST(1585)) +private define ES_STYLE_DOUBLE_CLICK_TEST (ES_STYLE_CAST(1585)) define ES_STYLE_ICON_DISPLAY (ES_STYLE_CAST(1265)) define ES_STYLE_ICON_DISPLAY_SMALL (ES_STYLE_CAST(1543)) define ES_STYLE_INSTALLER_ROOT (ES_STYLE_CAST(1267)) define ES_STYLE_LIST_CHOICE_BORDERED (ES_STYLE_CAST(1429)) define ES_STYLE_LIST_CHOICE_ITEM (ES_STYLE_CAST(1435)) -define_private ES_STYLE_LIST_COLUMN_HEADER (ES_STYLE_CAST(1269)) -define_private ES_STYLE_LIST_COLUMN_HEADER_ITEM (ES_STYLE_CAST(1271)) -define_private ES_STYLE_LIST_COLUMN_HEADER_ITEM_HAS_MENU (ES_STYLE_CAST(1273)) -define_private ES_STYLE_LIST_COLUMN_HEADER_SPLITTER (ES_STYLE_CAST(1275)) -define_private ES_STYLE_LIST_GROUP_HEADER_CELL (ES_STYLE_CAST(1277)) +private define ES_STYLE_LIST_COLUMN_HEADER (ES_STYLE_CAST(1269)) +private define ES_STYLE_LIST_COLUMN_HEADER_ITEM (ES_STYLE_CAST(1271)) +private define ES_STYLE_LIST_COLUMN_HEADER_ITEM_HAS_MENU (ES_STYLE_CAST(1273)) +private define ES_STYLE_LIST_COLUMN_HEADER_SPLITTER (ES_STYLE_CAST(1275)) +private define ES_STYLE_LIST_GROUP_HEADER_CELL (ES_STYLE_CAST(1277)) define ES_STYLE_LIST_ITEM (ES_STYLE_CAST(1279)) define ES_STYLE_LIST_ITEM_GROUP_FOOTER (ES_STYLE_CAST(1281)) define ES_STYLE_LIST_ITEM_GROUP_HEADER (ES_STYLE_CAST(1283)) define ES_STYLE_LIST_ITEM_TILE (ES_STYLE_CAST(1285)) -define_private ES_STYLE_LIST_PRIMARY_CELL (ES_STYLE_CAST(1287)) -define_private ES_STYLE_LIST_SECONDARY_CELL (ES_STYLE_CAST(1289)) -define_private ES_STYLE_LIST_SELECTED_CHOICE_CELL (ES_STYLE_CAST(1621)) -define_private ES_STYLE_LIST_SELECTION_BOX (ES_STYLE_CAST(1291)) +private define ES_STYLE_LIST_PRIMARY_CELL (ES_STYLE_CAST(1287)) +private define ES_STYLE_LIST_SECONDARY_CELL (ES_STYLE_CAST(1289)) +private define ES_STYLE_LIST_SELECTED_CHOICE_CELL (ES_STYLE_CAST(1621)) +private define ES_STYLE_LIST_SELECTION_BOX (ES_STYLE_CAST(1291)) define ES_STYLE_LIST_VIEW (ES_STYLE_CAST(1293)) define ES_STYLE_LIST_VIEW_BORDERED (ES_STYLE_CAST(1295)) define ES_STYLE_LIST_DISPLAY_DEFAULT (ES_STYLE_CAST(1441)) -define_private ES_STYLE_MARKER_DOWN_ARROW (ES_STYLE_CAST(1297)) -define_private ES_STYLE_MARKER_UP_ARROW (ES_STYLE_CAST(1501)) -define_private ES_STYLE_MENU_ITEM_HEADER (ES_STYLE_CAST(1299)) -define_private ES_STYLE_MENU_ITEM_NORMAL (ES_STYLE_CAST(1301)) -define_private ES_STYLE_MENU_SEPARATOR_HORIZONTAL (ES_STYLE_CAST(1303)) -define_private ES_STYLE_MENU_SEPARATOR_VERTICAL (ES_STYLE_CAST(1305)) -define_private ES_STYLE_PANEL_CONTAINER_WINDOW_ROOT (ES_STYLE_CAST(1307)) -define_private ES_STYLE_PANEL_CRASH_INFO (ES_STYLE_CAST(1309)) +private define ES_STYLE_MARKER_DOWN_ARROW (ES_STYLE_CAST(1297)) +private define ES_STYLE_MARKER_UP_ARROW (ES_STYLE_CAST(1501)) +private define ES_STYLE_MENU_ITEM_HEADER (ES_STYLE_CAST(1299)) +private define ES_STYLE_MENU_ITEM_NORMAL (ES_STYLE_CAST(1301)) +private define ES_STYLE_MENU_SEPARATOR_HORIZONTAL (ES_STYLE_CAST(1303)) +private define ES_STYLE_MENU_SEPARATOR_VERTICAL (ES_STYLE_CAST(1305)) +private define ES_STYLE_PANEL_CONTAINER_WINDOW_ROOT (ES_STYLE_CAST(1307)) +private define ES_STYLE_PANEL_CRASH_INFO (ES_STYLE_CAST(1309)) define ES_STYLE_PANEL_DIALOG_ROOT (ES_STYLE_CAST(1311)) define ES_STYLE_PANEL_DOCUMENT (ES_STYLE_CAST(1547)) define ES_STYLE_PANEL_FILLED (ES_STYLE_CAST(1313)) define ES_STYLE_PANEL_GROUP_BOX (ES_STYLE_CAST(1315)) define ES_STYLE_PANEL_INSET (ES_STYLE_CAST(1641)) -define_private ES_STYLE_PANEL_INSPECTOR_WINDOW_CONTAINER (ES_STYLE_CAST(1317)) -define_private ES_STYLE_PANEL_INSPECTOR_WINDOW_ROOT (ES_STYLE_CAST(1319)) -define_private ES_STYLE_PANEL_MENU_COLUMN (ES_STYLE_CAST(1321)) -define_private ES_STYLE_PANEL_MENU_CONTAINER (ES_STYLE_CAST(1323)) -define_private ES_STYLE_PANEL_MENU_ROOT (ES_STYLE_CAST(1325)) -define_private ES_STYLE_PANEL_MODAL_OVERLAY (ES_STYLE_CAST(1327)) -define_private ES_STYLE_PANEL_NORMAL_WINDOW_ROOT (ES_STYLE_CAST(1329)) +private define ES_STYLE_PANEL_INSPECTOR_WINDOW_CONTAINER (ES_STYLE_CAST(1317)) +private define ES_STYLE_PANEL_INSPECTOR_WINDOW_ROOT (ES_STYLE_CAST(1319)) +private define ES_STYLE_PANEL_MENU_COLUMN (ES_STYLE_CAST(1321)) +private define ES_STYLE_PANEL_MENU_CONTAINER (ES_STYLE_CAST(1323)) +private define ES_STYLE_PANEL_MENU_ROOT (ES_STYLE_CAST(1325)) +private define ES_STYLE_PANEL_MODAL_OVERLAY (ES_STYLE_CAST(1327)) +private define ES_STYLE_PANEL_NORMAL_WINDOW_ROOT (ES_STYLE_CAST(1329)) define ES_STYLE_PANEL_POPUP (ES_STYLE_CAST(1331)) define ES_STYLE_PANEL_SHEET (ES_STYLE_CAST(1333)) -define_private ES_STYLE_PANEL_SHUTDOWN_OVERLAY (ES_STYLE_CAST(1335)) +private define ES_STYLE_PANEL_SHUTDOWN_OVERLAY (ES_STYLE_CAST(1335)) define ES_STYLE_PANEL_STATUS_BAR (ES_STYLE_CAST(1489)) define ES_STYLE_PANEL_TOOLBAR (ES_STYLE_CAST(1337)) define ES_STYLE_PANEL_TOOLBAR_ROOT (ES_STYLE_CAST(1339)) @@ -73,34 +73,34 @@ define ES_STYLE_PANEL_WINDOW_BACKGROUND (ES_STYLE_CAST(1341)) define ES_STYLE_PANEL_WINDOW_DIVIDER (ES_STYLE_CAST(1343)) define ES_STYLE_PANEL_WINDOW_WITH_STATUS_BAR_CONTENT (ES_STYLE_CAST(1483)) define ES_STYLE_PUSH_BUTTON_DANGEROUS (ES_STYLE_CAST(1345)) -define_private ES_STYLE_PUSH_BUTTON_NORMAL (ES_STYLE_CAST(1347)) -define_private ES_STYLE_PUSH_BUTTON_NORMAL_COLOR_WELL (ES_STYLE_CAST(1349)) -define_private ES_STYLE_PUSH_BUTTON_SCROLLBAR_DOWN (ES_STYLE_CAST(1351)) -define_private ES_STYLE_PUSH_BUTTON_SCROLLBAR_LEFT (ES_STYLE_CAST(1353)) -define_private ES_STYLE_PUSH_BUTTON_SCROLLBAR_RIGHT (ES_STYLE_CAST(1355)) -define_private ES_STYLE_PUSH_BUTTON_SCROLLBAR_UP (ES_STYLE_CAST(1357)) +private define ES_STYLE_PUSH_BUTTON_NORMAL (ES_STYLE_CAST(1347)) +private define ES_STYLE_PUSH_BUTTON_NORMAL_COLOR_WELL (ES_STYLE_CAST(1349)) +private define ES_STYLE_PUSH_BUTTON_SCROLLBAR_DOWN (ES_STYLE_CAST(1351)) +private define ES_STYLE_PUSH_BUTTON_SCROLLBAR_LEFT (ES_STYLE_CAST(1353)) +private define ES_STYLE_PUSH_BUTTON_SCROLLBAR_RIGHT (ES_STYLE_CAST(1355)) +private define ES_STYLE_PUSH_BUTTON_SCROLLBAR_UP (ES_STYLE_CAST(1357)) define ES_STYLE_PUSH_BUTTON_STATUS_BAR (ES_STYLE_CAST(1495)) define ES_STYLE_PUSH_BUTTON_TOOLBAR (ES_STYLE_CAST(1359)) define ES_STYLE_PUSH_BUTTON_TOOLBAR_BIG (ES_STYLE_CAST(1457)) define ES_STYLE_PUSH_BUTTON_TOOLBAR_MEDIUM (ES_STYLE_CAST(1461)) -define_private ES_STYLE_SCROLLBAR_BAR_HORIZONTAL (ES_STYLE_CAST(1363)) -define_private ES_STYLE_SCROLLBAR_BAR_VERTICAL (ES_STYLE_CAST(1365)) -define_private ES_STYLE_SCROLLBAR_THUMB_HORIZONTAL (ES_STYLE_CAST(1367)) -define_private ES_STYLE_SCROLLBAR_THUMB_VERTICAL (ES_STYLE_CAST(1369)) -define_private ES_STYLE_SCROLLBAR_PAD (ES_STYLE_CAST(1371)) +private define ES_STYLE_SCROLLBAR_BAR_HORIZONTAL (ES_STYLE_CAST(1363)) +private define ES_STYLE_SCROLLBAR_BAR_VERTICAL (ES_STYLE_CAST(1365)) +private define ES_STYLE_SCROLLBAR_THUMB_HORIZONTAL (ES_STYLE_CAST(1367)) +private define ES_STYLE_SCROLLBAR_THUMB_VERTICAL (ES_STYLE_CAST(1369)) +private define ES_STYLE_SCROLLBAR_PAD (ES_STYLE_CAST(1371)) define ES_STYLE_SEPARATOR_HORIZONTAL (ES_STYLE_CAST(1373)) -define_private ES_STYLE_SLIDER_POINT (ES_STYLE_CAST(1607)) -define_private ES_STYLE_SLIDER_TRACK (ES_STYLE_CAST(1601)) -define_private ES_STYLE_SPLIT_BAR_HORIZONTAL (ES_STYLE_CAST(1375)) -define_private ES_STYLE_SPLIT_BAR_VERTICAL (ES_STYLE_CAST(1377)) -define_private ES_STYLE_TASK_BAR_BAR (ES_STYLE_CAST(1379)) -define_private ES_STYLE_TASK_BAR_BUTTON (ES_STYLE_CAST(1381)) -define_private ES_STYLE_TASK_BAR_EXTRA (ES_STYLE_CAST(1507)) -define_private ES_STYLE_TASK_BAR_NEW_WINDOW (ES_STYLE_CAST(1383)) +private define ES_STYLE_SLIDER_POINT (ES_STYLE_CAST(1607)) +private define ES_STYLE_SLIDER_TRACK (ES_STYLE_CAST(1601)) +private define ES_STYLE_SPLIT_BAR_HORIZONTAL (ES_STYLE_CAST(1375)) +private define ES_STYLE_SPLIT_BAR_VERTICAL (ES_STYLE_CAST(1377)) +private define ES_STYLE_TASK_BAR_BAR (ES_STYLE_CAST(1379)) +private define ES_STYLE_TASK_BAR_BUTTON (ES_STYLE_CAST(1381)) +private define ES_STYLE_TASK_BAR_EXTRA (ES_STYLE_CAST(1507)) +private define ES_STYLE_TASK_BAR_NEW_WINDOW (ES_STYLE_CAST(1383)) define ES_STYLE_TEXT_HEADING0 (ES_STYLE_CAST(1387)) define ES_STYLE_TEXT_HEADING1 (ES_STYLE_CAST(1581)) define ES_STYLE_TEXT_HEADING2 (ES_STYLE_CAST(1389)) -define_private ES_STYLE_TEXT_HEADING3 (ES_STYLE_CAST(1423)) +private define ES_STYLE_TEXT_HEADING3 (ES_STYLE_CAST(1423)) define ES_STYLE_TEXT_LABEL (ES_STYLE_CAST(1391)) define ES_STYLE_TEXT_LABEL_INVERTED (ES_STYLE_CAST(1393)) define ES_STYLE_TEXT_LABEL_SECONDARY (ES_STYLE_CAST(1395)) @@ -111,12 +111,12 @@ define ES_STYLE_TEXT_TOOLBAR (ES_STYLE_CAST(1553)) define ES_STYLE_TEXTBOX_BORDERED_MULTILINE (ES_STYLE_CAST(1399)) define ES_STYLE_TEXTBOX_BORDERED_SINGLE (ES_STYLE_CAST(1401)) define ES_STYLE_TEXTBOX_BORDERED_SINGLE_COMPACT (ES_STYLE_CAST(1403)) -define_private ES_STYLE_TEXTBOX_INLINE (ES_STYLE_CAST(1477)) -define_private ES_STYLE_TEXTBOX_MARGIN (ES_STYLE_CAST(1415)) +private define ES_STYLE_TEXTBOX_INLINE (ES_STYLE_CAST(1477)) +private define ES_STYLE_TEXTBOX_MARGIN (ES_STYLE_CAST(1415)) define ES_STYLE_TEXTBOX_NO_BORDER (ES_STYLE_CAST(1405)) define ES_STYLE_TEXTBOX_TRANSPARENT (ES_STYLE_CAST(1445)) -define_private ES_STYLE_WINDOW_TAB_ACTIVE (ES_STYLE_CAST(1407)) -define_private ES_STYLE_WINDOW_TAB_CLOSE_BUTTON (ES_STYLE_CAST(1469)) -define_private ES_STYLE_WINDOW_TAB_INACTIVE (ES_STYLE_CAST(1409)) -define_private ES_STYLE_WINDOW_TAB_BAND (ES_STYLE_CAST(1411)) -define_private ES_STYLE_WINDOW_TAB_BAND_NEW (ES_STYLE_CAST(1361)) +private define ES_STYLE_WINDOW_TAB_ACTIVE (ES_STYLE_CAST(1407)) +private define ES_STYLE_WINDOW_TAB_CLOSE_BUTTON (ES_STYLE_CAST(1469)) +private define ES_STYLE_WINDOW_TAB_INACTIVE (ES_STYLE_CAST(1409)) +private define ES_STYLE_WINDOW_TAB_BAND (ES_STYLE_CAST(1411)) +private define ES_STYLE_WINDOW_TAB_BAND_NEW (ES_STYLE_CAST(1361)) diff --git a/shared/common.cpp b/shared/common.cpp index 1578a7e..14e4a49 100644 --- a/shared/common.cpp +++ b/shared/common.cpp @@ -2677,6 +2677,11 @@ void *EsBufferWrite(EsBuffer *buffer, const void *source, size_t writeBytes) { } } +bool EsBufferWriteInt8(EsBuffer *buffer, int8_t value) { + EsBufferWrite(buffer, &value, sizeof(int8_t)); + return buffer->error; +} + bool EsBufferWriteInt32Endian(EsBuffer *buffer, int32_t value) { #ifdef __BIG_ENDIAN__ value = ByteSwap32(value); diff --git a/shared/strings.cpp b/shared/strings.cpp index 2c88568..a445f4c 100644 --- a/shared/strings.cpp +++ b/shared/strings.cpp @@ -33,6 +33,7 @@ DEFINE_INTERFACE_STRING(CommonFileMakeCopy, "Make a copy"); DEFINE_INTERFACE_STRING(CommonFileVersionHistory, "Version history" ELLIPSIS); DEFINE_INTERFACE_STRING(CommonFileShowInFileManager, "Show in File Manager" ELLIPSIS); DEFINE_INTERFACE_STRING(CommonFileMenuFileSize, "Size:"); +DEFINE_INTERFACE_STRING(CommonFileMenuFileLocation, "Location:"); DEFINE_INTERFACE_STRING(CommonFileUnchanged, "(All changes saved.)"); DEFINE_INTERFACE_STRING(CommonSearchOpen, "Search"); diff --git a/util/api_table.ini b/util/api_table.ini index b06cfd8..9f7f741 100644 --- a/util/api_table.ini +++ b/util/api_table.ini @@ -378,7 +378,6 @@ EsMountPointEnumerate=376 EsMountPointGetVolumeInformation=377 EsListViewInvalidateAll=378 EsListViewGetFocusedItem=379 -EsInstanceGetStartupInformation=380 EsPathQueryInformation=381 EsListViewCreateInlineTextbox=382 EsTextboxStartEdit=383 @@ -457,3 +456,5 @@ EsWorkQueue=455 EsWorkIsExiting=456 EsPanelRadioGroupGetChecked=457 EsTextboxEnableSmartQuotes=458 +EsBufferWriteInt8=459 +EsInstanceGetStartupRequest=460 diff --git a/util/designer/designer.c b/util/designer/designer.c index ace3e25..c11b924 100644 --- a/util/designer/designer.c +++ b/util/designer/designer.c @@ -1403,7 +1403,7 @@ void StyleSetOp(RfState *state, RfItem *item, void *pointer) { printf("exporting '%.*s' (id: %ld)\n", (int) style->name.byteCount, (char *) style->name.buffer, (style->id << 1) | 1); if (style->id && stylesPath) { - fprintf(f, "%s ES_STYLE_", style->publicStyle ? "define" : "define_private"); + fprintf(f, "%s ES_STYLE_", style->publicStyle ? "define" : "private define"); bool dot = false; diff --git a/util/header_generator.c b/util/header_generator.c index 1013d0b..a3ca774 100644 --- a/util/header_generator.c +++ b/util/header_generator.c @@ -37,14 +37,13 @@ typedef struct Token { #define TOKEN_API_TYPE (29) #define TOKEN_FUNCTION_POINTER (30) #define TOKEN_TYPE_NAME (31) -#define TOKEN_DEFINE_PRIVATE (32) +#define TOKEN_PRIVATE (32) int type, value; char *text; } Token; #define ENTRY_ROOT (0) #define ENTRY_DEFINE (1) -#define ENTRY_DEFINE_PRIVATE (2) #define ENTRY_ENUM (3) #define ENTRY_STRUCT (4) #define ENTRY_UNION (5) @@ -59,6 +58,8 @@ typedef struct Entry { char *name; struct Entry *children; + bool isPrivate; + union { struct { char *type, *arraySize, *initialValue; @@ -146,7 +147,6 @@ Token NextToken() { #define COMPARE_KEYWORD(x, y) if (strlen(x) == token.value && 0 == memcmp(x, token.text, token.value)) token.type = y COMPARE_KEYWORD("define", TOKEN_DEFINE); - COMPARE_KEYWORD("define_private", TOKEN_DEFINE_PRIVATE); COMPARE_KEYWORD("enum", TOKEN_ENUM); COMPARE_KEYWORD("struct", TOKEN_STRUCT); COMPARE_KEYWORD("function", TOKEN_FUNCTION); @@ -158,6 +158,7 @@ Token NextToken() { COMPARE_KEYWORD("opaque_type", TOKEN_API_TYPE); COMPARE_KEYWORD("function_pointer", TOKEN_FUNCTION_POINTER); COMPARE_KEYWORD("type_name", TOKEN_TYPE_NAME); + COMPARE_KEYWORD("private", TOKEN_PRIVATE); } else { @@ -296,25 +297,16 @@ void ParseFile(Entry *root, const char *name) { position = 0; Token token; - bool nextToken = true; + bool isPrivate = false; while (true) { - if (nextToken) token = NextToken(); - nextToken = true; + token = NextToken(); if (token.type == TOKEN_DEFINE) { Token identifier = NextToken(); size_t length = 0; while (!FoundEndOfLine(length)) length++; - Entry entry = { .type = ENTRY_DEFINE, .name = TokenToString(identifier) }; - entry.define.value = TokenToString((Token) { .value = (int) length, .text = buffer + position }); - arrput(root->children, entry); - position += length; - } else if (token.type == TOKEN_DEFINE_PRIVATE) { - Token identifier = NextToken(); - size_t length = 0; - while (!FoundEndOfLine(length)) length++; - Entry entry = { .type = ENTRY_DEFINE_PRIVATE, .name = TokenToString(identifier) }; + Entry entry = { .type = ENTRY_DEFINE, .name = TokenToString(identifier), .isPrivate = isPrivate }; entry.define.value = TokenToString((Token) { .value = (int) length, .text = buffer + position }); arrput(root->children, entry); position += length; @@ -334,7 +326,7 @@ void ParseFile(Entry *root, const char *name) { assert(name.type == TOKEN_IDENTIFIER); assert(NextToken().type == TOKEN_LEFT_BRACE); - Entry entry = { .type = ENTRY_ENUM, .name = TokenToString(name) }; + Entry entry = { .type = ENTRY_ENUM, .name = TokenToString(name), .isPrivate = isPrivate }; Token token = NextToken(); while (true) { @@ -364,6 +356,7 @@ void ParseFile(Entry *root, const char *name) { assert(structName.type == TOKEN_IDENTIFIER); assert(NextToken().type == TOKEN_LEFT_BRACE); Entry entry = ParseRecord(false); + entry.isPrivate = isPrivate; entry.name = TokenToString(structName); arrput(root->children, entry); } else if (token.type == TOKEN_FUNCTION || token.type == TOKEN_FUNCTION_NOT_IN_KERNEL @@ -371,7 +364,7 @@ void ParseFile(Entry *root, const char *name) { bool inKernel = token.type != TOKEN_FUNCTION_NOT_IN_KERNEL; Entry objectFunctionType; bool firstVariable = true; - Entry entry = { .type = ENTRY_FUNCTION, .function = { .inKernel = inKernel, .apiArrayIndex = 0 } }; + Entry entry = { .type = ENTRY_FUNCTION, .isPrivate = isPrivate, .function = { .inKernel = inKernel, .apiArrayIndex = 0 } }; if (token.type == TOKEN_FUNCTION_POINTER) { entry.function.functionPointer = true; @@ -395,15 +388,18 @@ void ParseFile(Entry *root, const char *name) { arrput(root->children, entry); } else if (token.type == TOKEN_TYPE_NAME) { Token oldName = NextToken(), newName = NextToken(); - Entry entry = { .type = ENTRY_TYPE_NAME, .name = TokenToString(newName), .oldTypeName = TokenToString(oldName) }; + Entry entry = { .type = ENTRY_TYPE_NAME, .isPrivate = isPrivate, .name = TokenToString(newName), .oldTypeName = TokenToString(oldName) }; arrput(root->children, entry); } else if (token.type == TOKEN_SEMICOLON) { + } else if (token.type == TOKEN_PRIVATE) { } else if (token.type == TOKEN_EOF) { break; } else { Log("unexpected token '%.*s' at top level\n", token.value, token.text); exit(1); } + + isPrivate = token.type == TOKEN_PRIVATE; } free(buffer); @@ -593,10 +589,12 @@ void OutputC(Entry *root) { for (int i = 0; i < arrlen(root->children); i++) { Entry *entry = root->children + i; + if (entry->isPrivate) { + FilePrintFormat(output, "#if defined(ES_API) || defined(KERNEL) || defined(INSTALLER)\n"); + } + if (entry->type == ENTRY_DEFINE) { FilePrintFormat(output, "#define %s (%s)\n", entry->name, entry->define.value); - } else if (entry->type == ENTRY_DEFINE_PRIVATE) { - FilePrintFormat(output, "#ifdef ES_API\n#define %s (%s)\n#endif\n", entry->name, entry->define.value); } else if (entry->type == ENTRY_STRUCT) { FilePrintFormat(output, "typedef struct %s {\n", entry->name); OutputCRecord(entry, 0); @@ -640,6 +638,10 @@ void OutputC(Entry *root) { } else if (entry->type == ENTRY_TYPE_NAME) { FilePrintFormat(output, "typedef %s %s;\n", entry->oldTypeName, entry->name); } + + if (entry->isPrivate) { + FilePrintFormat(output, "#endif\n"); + } } for (int i = 0; i < arrlen(root->children); i++) { @@ -901,6 +903,7 @@ void OutputOdin(Entry *root) { for (int i = 0; i < arrlen(root->children); i++) { Entry *entry = root->children + i; + if (entry->isPrivate) continue; if (entry->type == ENTRY_DEFINE) { const char *styleCast = strstr(entry->define.value, "STYLE_CAST("); @@ -1128,6 +1131,7 @@ void OutputZig(Entry *root) { for (int i = 0; i < arrlen(root->children); i++) { Entry *entry = root->children + i; + if (entry->isPrivate) continue; if (entry->type == ENTRY_DEFINE) { FilePrintFormat(output, "pub const %s = %s;\n", TrimPrefix(entry->name), ZigReplaceTypes(entry->define.value, false));