ini files: remove sectionClass

This commit is contained in:
nakst 2022-03-16 12:04:34 +00:00
parent f0483e4bfe
commit aa4b656bbd
23 changed files with 155 additions and 159 deletions

View File

@ -12,109 +12,109 @@ background_service=1
[build] [build]
source=apps/file_manager/main.cpp source=apps/file_manager/main.cpp
[@file_type] [file_type]
extension=esx extension=esx
name=Executable name=Executable
icon=icon_application_default_icon icon=icon_application_default_icon
[@file_type] [file_type]
extension=ini extension=ini
name=Configuration file name=Configuration file
icon=icon_application_x_desktop icon=icon_application_x_desktop
[@file_type] [file_type]
extension=esx_symbols extension=esx_symbols
name=Debugging data name=Debugging data
icon=icon_extension icon=icon_extension
[@file_type] [file_type]
extension=exe extension=exe
name=PC executable name=PC executable
icon=icon_application_x_ms_dos_executable icon=icon_application_x_ms_dos_executable
[@file_type] [file_type]
extension=png extension=png
name=PNG image name=PNG image
icon=icon_image_x_generic icon=icon_image_x_generic
has_thumbnail_generator=1 has_thumbnail_generator=1
[@file_type] [file_type]
extension=jpg extension=jpg
name=JPG image name=JPG image
icon=icon_image_x_generic icon=icon_image_x_generic
has_thumbnail_generator=1 has_thumbnail_generator=1
[@file_type] [file_type]
extension=ttf extension=ttf
name=TrueType font name=TrueType font
icon=icon_font_x_generic icon=icon_font_x_generic
[@file_type] [file_type]
extension=otf extension=otf
name=OpenType font name=OpenType font
icon=icon_font_x_generic icon=icon_font_x_generic
[@file_type] [file_type]
extension=a extension=a
name=Static library name=Static library
icon=icon_extension icon=icon_extension
[@file_type] [file_type]
extension=dat extension=dat
name=Database name=Database
icon=icon_office_database icon=icon_office_database
[@file_type] [file_type]
extension=icon_pack extension=icon_pack
name=Icon pack name=Icon pack
icon=icon_package_x_generic icon=icon_package_x_generic
[@file_type] [file_type]
extension=ekm extension=ekm
name=Kernel module name=Kernel module
icon=icon_extension icon=icon_extension
[@file_type] [file_type]
extension=o extension=o
name=Binary object name=Binary object
icon=icon_extension icon=icon_extension
[@file_type] [file_type]
extension=c extension=c
name=C source name=C source
icon=icon_text_x_csrc icon=icon_text_x_csrc
[@file_type] [file_type]
extension=cpp extension=cpp
name=C++ source name=C++ source
icon=icon_text_x_csrc icon=icon_text_x_csrc
[@file_type] [file_type]
extension=h extension=h
name=C header name=C header
icon=icon_text_x_csrc icon=icon_text_x_csrc
[@file_type] [file_type]
extension=txt extension=txt
name=Text file name=Text file
icon=icon_text icon=icon_text
[@file_type] [file_type]
extension=md extension=md
name=Markdown file name=Markdown file
icon=icon_text_markdown icon=icon_text_markdown
[@file_type] [file_type]
extension=ogg extension=ogg
name=OGG audio name=OGG audio
icon=icon_audio_x_generic icon=icon_audio_x_generic
[@file_type] [file_type]
extension=mp4 extension=mp4
name=MP4 video name=MP4 video
icon=icon_view_list_video_symbolic icon=icon_view_list_video_symbolic
[@file_type] [file_type]
extension=wav extension=wav
name=Wave audio name=Wave audio
icon=icon_audio_x_generic icon=icon_audio_x_generic

View File

@ -393,7 +393,7 @@ void ConfigurationSave() {
for (uintptr_t i = 0; i < folderViewSettings.Length(); i++) { for (uintptr_t i = 0; i < folderViewSettings.Length(); i++) {
FolderViewSettingsEntry *entry = &folderViewSettings[i]; FolderViewSettingsEntry *entry = &folderViewSettings[i];
EsBufferFormat(&buffer, "\n[@folder]\npath=%z\nsort_column=%d\nview_type=%d\n", EsBufferFormat(&buffer, "\n[folder]\npath=%z\nsort_column=%d\nview_type=%d\n",
entry->path, entry->settings.sortColumn, entry->settings.viewType); entry->path, entry->settings.sortColumn, entry->settings.viewType);
} }
@ -490,7 +490,7 @@ void LoadSettings() {
String string = {}; String string = {};
string.text = state.value, string.bytes = state.valueBytes; string.text = state.value, string.bytes = state.valueBytes;
BookmarkAdd(string, false); BookmarkAdd(string, false);
} else if (0 == EsStringCompareRaw(state.sectionClass, state.sectionClassBytes, EsLiteral("folder"))) { } else if (0 == EsStringCompareRaw(state.section, state.sectionBytes, EsLiteral("folder"))) {
if (0 == EsStringCompareRaw(state.key, state.keyBytes, EsLiteral("path"))) { if (0 == EsStringCompareRaw(state.key, state.keyBytes, EsLiteral("path"))) {
if (state.keyBytes < sizeof(folderViewSettings[0].path)) { if (state.keyBytes < sizeof(folderViewSettings[0].path)) {
FolderViewSettingsEntry *entry = folderViewSettings.Add(); FolderViewSettingsEntry *entry = folderViewSettings.Add();

View File

@ -5,10 +5,10 @@ icon=icon_applications_fonts
[build] [build]
source=apps/font_book.cpp source=apps/font_book.cpp
[@handler] [handler]
extension=ttf extension=ttf
action=open action=open
[@handler] [handler]
extension=otf extension=otf
action=open action=open

View File

@ -6,10 +6,10 @@ use_single_process=1
[build] [build]
source=apps/image_editor.cpp source=apps/image_editor.cpp
[@handler] [handler]
extension=jpg extension=jpg
action=open action=open
[@handler] [handler]
extension=png extension=png
action=open action=open

View File

@ -7,6 +7,6 @@ hidden=1
[build] [build]
source=apps/markdown_viewer.cpp source=apps/markdown_viewer.cpp
[@handler] [handler]
extension=md extension=md
action=open action=open

View File

@ -6,22 +6,22 @@ use_single_process=1
[build] [build]
source=apps/text_editor.cpp source=apps/text_editor.cpp
[@handler] [handler]
extension=txt extension=txt
action=open action=open
[@handler] [handler]
extension=cpp extension=cpp
action=open action=open
[@handler] [handler]
extension=h extension=h
action=open action=open
[@handler] [handler]
extension=c extension=c
action=open action=open
[@handler] [handler]
extension=ini extension=ini
action=open action=open

View File

@ -110,8 +110,8 @@ struct SystemConfigurationItem {
}; };
struct SystemConfigurationGroup { struct SystemConfigurationGroup {
char *section, *sectionClass; char *section;
size_t sectionBytes, sectionClassBytes; size_t sectionBytes;
SystemConfigurationItem *items; SystemConfigurationItem *items;
size_t itemCount; size_t itemCount;
}; };
@ -331,8 +331,7 @@ SystemConfigurationGroup *SystemConfigurationGetGroup(const char *section, ptrdi
if (sectionBytes == -1) sectionBytes = EsCStringLength(section); if (sectionBytes == -1) sectionBytes = EsCStringLength(section);
for (uintptr_t i = 0; i < api.systemConfigurationGroups.Length(); i++) { for (uintptr_t i = 0; i < api.systemConfigurationGroups.Length(); i++) {
if (0 == EsStringCompareRaw(section, sectionBytes, api.systemConfigurationGroups[i].section, api.systemConfigurationGroups[i].sectionBytes) if (0 == EsStringCompareRaw(section, sectionBytes, api.systemConfigurationGroups[i].section, api.systemConfigurationGroups[i].sectionBytes)) {
&& !api.systemConfigurationGroups[i].sectionClassBytes) {
return &api.systemConfigurationGroups[i]; return &api.systemConfigurationGroups[i];
} }
} }
@ -396,7 +395,6 @@ void SystemConfigurationUnload() {
} }
EsHeapFree(api.systemConfigurationGroups[i].section); EsHeapFree(api.systemConfigurationGroups[i].section);
EsHeapFree(api.systemConfigurationGroups[i].sectionClass);
Array<SystemConfigurationItem> items = { api.systemConfigurationGroups[i].items }; Array<SystemConfigurationItem> items = { api.systemConfigurationGroups[i].items };
items.Free(); items.Free();
@ -421,8 +419,6 @@ void SystemConfigurationLoad(const char *file, size_t fileBytes) {
group = &api.systemConfigurationGroups.Last(); group = &api.systemConfigurationGroups.Last();
group->section = (char *) EsHeapAllocate(s.sectionBytes, false); group->section = (char *) EsHeapAllocate(s.sectionBytes, false);
EsMemoryCopy(group->section, s.section, (group->sectionBytes = s.sectionBytes)); EsMemoryCopy(group->section, s.section, (group->sectionBytes = s.sectionBytes));
group->sectionClass = (char *) EsHeapAllocate(s.sectionClassBytes, false);
EsMemoryCopy(group->sectionClass, s.sectionClass, (group->sectionClassBytes = s.sectionClassBytes));
} else if (group) { } else if (group) {
SystemConfigurationItem item = {}; SystemConfigurationItem item = {};
item.key = (char *) EsHeapAllocate(s.keyBytes, false); item.key = (char *) EsHeapAllocate(s.keyBytes, false);

View File

@ -2476,7 +2476,7 @@ void ConfigurationLoadApplications() {
SystemConfigurationGroup *group = &api.systemConfigurationGroups[i]; SystemConfigurationGroup *group = &api.systemConfigurationGroups[i];
if (0 != EsStringCompareRaw(group->sectionClass, group->sectionClassBytes, EsLiteral("application"))) { if (0 != EsStringCompareRaw(group->section, group->sectionBytes, EsLiteral("application"))) {
continue; continue;
} }
@ -2491,7 +2491,7 @@ void ConfigurationLoadApplications() {
application->useSingleProcess = SystemConfigurationGroupReadInteger(group, EsLiteral("use_single_process"), false); application->useSingleProcess = SystemConfigurationGroupReadInteger(group, EsLiteral("use_single_process"), false);
application->useSingleInstance = SystemConfigurationGroupReadInteger(group, EsLiteral("use_single_instance"), false); application->useSingleInstance = SystemConfigurationGroupReadInteger(group, EsLiteral("use_single_instance"), false);
application->hidden = SystemConfigurationGroupReadInteger(group, EsLiteral("hidden"), false); application->hidden = SystemConfigurationGroupReadInteger(group, EsLiteral("hidden"), false);
application->id = EsIntegerParse(group->section, group->sectionBytes); application->id = SystemConfigurationGroupReadInteger(group, EsLiteral("id"), false);
#define READ_PERMISSION(x, y) if (SystemConfigurationGroupReadInteger(group, EsLiteral(x), 0)) application->permissions |= y #define READ_PERMISSION(x, y) if (SystemConfigurationGroupReadInteger(group, EsLiteral(x), 0)) application->permissions |= y
READ_PERMISSION("permission_all_files", APPLICATION_PERMISSION_ALL_FILES); READ_PERMISSION("permission_all_files", APPLICATION_PERMISSION_ALL_FILES);
@ -2529,20 +2529,22 @@ void ConfigurationLoadApplications() {
}, 0); }, 0);
} }
void ConfigurationWriteSectionsToBuffer(const char *sectionClass, const char *section, bool includeComments, EsBuffer *pipe) { void ConfigurationWriteSectionsToBuffer(const char *section, bool includeComments, EsBuffer *pipe) {
char buffer[4096]; char buffer[4096];
EsMutexAcquire(&api.systemConfigurationMutex); EsMutexAcquire(&api.systemConfigurationMutex);
for (uintptr_t i = 0; i < api.systemConfigurationGroups.Length(); i++) { for (uintptr_t i = 0; i < api.systemConfigurationGroups.Length(); i++) {
SystemConfigurationGroup *group = &api.systemConfigurationGroups[i]; SystemConfigurationGroup *group = &api.systemConfigurationGroups[i];
if ((sectionClass && EsStringCompareRaw(group->sectionClass, group->sectionClassBytes, sectionClass, -1)) if (section) {
|| (section && EsStringCompareRaw(group->section, group->sectionBytes, section, -1))) { if (section[EsCStringLength(section) - 1] == ':') {
continue; if (group->sectionBytes <= EsCStringLength(section) || EsMemoryCompare(group->section, section, EsCStringLength(section))) continue;
} else {
if (EsStringCompareRaw(group->section, group->sectionBytes, section, -1)) continue;
}
} }
EsINIState s = {}; EsINIState s = {};
s.sectionClass = group->sectionClass, s.sectionClassBytes = group->sectionClassBytes;
s.section = group->section, s.sectionBytes = group->sectionBytes; s.section = group->section, s.sectionBytes = group->sectionBytes;
size_t bytes = EsINIFormat(&s, buffer, sizeof(buffer)); size_t bytes = EsINIFormat(&s, buffer, sizeof(buffer));
EsBufferWrite(pipe, buffer, bytes); EsBufferWrite(pipe, buffer, bytes);
@ -2570,7 +2572,7 @@ void ConfigurationWriteToFile() {
} }
EsBuffer buffer = { .canGrow = true }; EsBuffer buffer = { .canGrow = true };
ConfigurationWriteSectionsToBuffer(nullptr, nullptr, true /* include comments */, &buffer); ConfigurationWriteSectionsToBuffer(nullptr, true /* include comments */, &buffer);
if (!buffer.error) { if (!buffer.error) {
if (ES_SUCCESS == EsFileWriteAll(EsLiteral(K_SYSTEM_CONFIGURATION "_"), buffer.out, buffer.position)) { if (ES_SUCCESS == EsFileWriteAll(EsLiteral(K_SYSTEM_CONFIGURATION "_"), buffer.out, buffer.position)) {
@ -2900,18 +2902,18 @@ bool /* returns false on fatal error */ DesktopSyscall(EsObjectID windowID, Appl
EsBufferWrite(pipe, &desktop.clipboardInformation, sizeof(desktop.clipboardInformation)); EsBufferWrite(pipe, &desktop.clipboardInformation, sizeof(desktop.clipboardInformation));
EsBufferWrite(pipe, &fileHandle, sizeof(fileHandle)); EsBufferWrite(pipe, &fileHandle, sizeof(fileHandle));
} else if (buffer[0] == DESKTOP_MSG_SYSTEM_CONFIGURATION_GET && pipe) { } else if (buffer[0] == DESKTOP_MSG_SYSTEM_CONFIGURATION_GET && pipe) {
ConfigurationWriteSectionsToBuffer("font", nullptr, false, pipe); ConfigurationWriteSectionsToBuffer("font:", false, pipe);
ConfigurationWriteSectionsToBuffer(nullptr, "ui_fonts", false, pipe); ConfigurationWriteSectionsToBuffer("ui_fonts", false, pipe);
if (application->permissions & APPLICATION_PERMISSION_ALL_FILES) { if (application->permissions & APPLICATION_PERMISSION_ALL_FILES) {
ConfigurationWriteSectionsToBuffer(nullptr, "paths", false, pipe); ConfigurationWriteSectionsToBuffer("paths", false, pipe);
} }
} else if (buffer[0] == DESKTOP_MSG_REQUEST_SHUTDOWN) { } else if (buffer[0] == DESKTOP_MSG_REQUEST_SHUTDOWN) {
if (~application->permissions & APPLICATION_PERMISSION_SHUTDOWN) return false; if (~application->permissions & APPLICATION_PERMISSION_SHUTDOWN) return false;
ShutdownModalCreate(); ShutdownModalCreate();
} else if (buffer[0] == DESKTOP_MSG_FILE_TYPES_GET && pipe) { } else if (buffer[0] == DESKTOP_MSG_FILE_TYPES_GET && pipe) {
if (~application->permissions & APPLICATION_PERMISSION_VIEW_FILE_TYPES) return false; if (~application->permissions & APPLICATION_PERMISSION_VIEW_FILE_TYPES) return false;
ConfigurationWriteSectionsToBuffer("file_type", nullptr, false, pipe); ConfigurationWriteSectionsToBuffer("file_type", false, pipe);
} else if (buffer[0] == DESKTOP_MSG_ANNOUNCE_PATH_MOVED && bytes > 1 + sizeof(uintptr_t) * 2) { } else if (buffer[0] == DESKTOP_MSG_ANNOUNCE_PATH_MOVED && bytes > 1 + sizeof(uintptr_t) * 2) {
if (~application->permissions & APPLICATION_PERMISSION_ALL_FILES) return false; if (~application->permissions & APPLICATION_PERMISSION_ALL_FILES) return false;

View File

@ -1561,8 +1561,8 @@ private struct _EsApplicationStartupInformation {
}; };
struct EsINIState { struct EsINIState {
char *buffer, *sectionClass, *section, *key, *value; char *buffer, *section, *key, *value;
size_t bytes, sectionClassBytes, sectionBytes, keyBytes, valueBytes; size_t bytes, sectionBytes, keyBytes, valueBytes;
} @opaque(); } @opaque();
struct EsAnalogInput { struct EsAnalogInput {

View File

@ -587,27 +587,30 @@ void FontInitialise() {
for (uintptr_t i = 0; i < api.systemConfigurationGroups.Length(); i++) { for (uintptr_t i = 0; i < api.systemConfigurationGroups.Length(); i++) {
SystemConfigurationGroup *g = &api.systemConfigurationGroups[i]; SystemConfigurationGroup *g = &api.systemConfigurationGroups[i];
if (0 == EsStringCompareRaw(g->sectionClass, g->sectionClassBytes, EsLiteral("font"))) { if (g->sectionBytes > 5 && 0 == EsMemoryCompare(g->section, "font:", 5)) {
if (0 == EsStringCompareRaw(g->section, g->sectionBytes, EsLiteral(fontManagement.sansName))) { const char *name = g->section + 5;
size_t nameBytes = g->sectionBytes - 5;
if (0 == EsStringCompareRaw(name, nameBytes, EsLiteral(fontManagement.sansName))) {
fontManagement.sans = fontManagement.database.Length(); fontManagement.sans = fontManagement.database.Length();
} }
if (0 == EsStringCompareRaw(g->section, g->sectionBytes, EsLiteral(fontManagement.serifName))) { if (0 == EsStringCompareRaw(name, nameBytes, EsLiteral(fontManagement.serifName))) {
fontManagement.serif = fontManagement.database.Length(); fontManagement.serif = fontManagement.database.Length();
} }
if (0 == EsStringCompareRaw(g->section, g->sectionBytes, EsLiteral(fontManagement.monospacedName))) { if (0 == EsStringCompareRaw(name, nameBytes, EsLiteral(fontManagement.monospacedName))) {
fontManagement.monospaced = fontManagement.database.Length(); fontManagement.monospaced = fontManagement.database.Length();
} }
if (0 == EsStringCompareRaw(g->section, g->sectionBytes, EsLiteral(fontManagement.fallbackName))) { if (0 == EsStringCompareRaw(name, nameBytes, EsLiteral(fontManagement.fallbackName))) {
fontManagement.fallback = fontManagement.database.Length(); fontManagement.fallback = fontManagement.database.Length();
} }
FontDatabaseEntry entry = {}; FontDatabaseEntry entry = {};
entry.nameBytes = MinimumInteger(g->sectionBytes, sizeof(entry.name)); entry.nameBytes = MinimumInteger(nameBytes, sizeof(entry.name));
EsMemoryCopy(entry.name, g->section, entry.nameBytes); EsMemoryCopy(entry.name, name, entry.nameBytes);
entry.id = fontManagement.database.Length(); entry.id = fontManagement.database.Length();
for (uintptr_t i = 0; i < g->itemCount; i++) { for (uintptr_t i = 0; i < g->itemCount; i++) {

View File

@ -233,8 +233,8 @@ When a thread is waiting for a spinlock to be released so that it may acquire it
```c ```c
struct EsINIState { struct EsINIState {
char *buffer, *sectionClass, *section, *key, *value; char *buffer, *section, *key, *value;
size_t bytes, sectionClassBytes, sectionBytes, keyBytes, valueBytes; size_t bytes, sectionBytes, keyBytes, valueBytes;
}; };
bool EsINIParse(EsINIState *s); bool EsINIParse(EsINIState *s);
@ -247,11 +247,11 @@ void EsINIZeroTerminate(EsINIState *s);
To parse an INI file, first initialise a blank EsINIState structure. Set `buffer` to point to the INI data, and set `bytes` to the byte count of the data. Then, call `EsINIParse` repeatedly, until it returns false, indicating it has reached the end of the data. After each call to `EsINIParse`, the fields of `EsINIState` are updated to give the information about the last parsed line in the INI file. `EsINIPeek` is the same as `EsINIParse` except it does not advance to the next line in the INI data. Fields in `EsINIState` that are not applicable to the parsed line are set to empty strings. Comment lines set `key` to `;` and `value` contains the comment itself. Aside for empty strings, the fields in `EsINIState` will always point into the provided buffer. To parse an INI file, first initialise a blank EsINIState structure. Set `buffer` to point to the INI data, and set `bytes` to the byte count of the data. Then, call `EsINIParse` repeatedly, until it returns false, indicating it has reached the end of the data. After each call to `EsINIParse`, the fields of `EsINIState` are updated to give the information about the last parsed line in the INI file. `EsINIPeek` is the same as `EsINIParse` except it does not advance to the next line in the INI data. Fields in `EsINIState` that are not applicable to the parsed line are set to empty strings. Comment lines set `key` to `;` and `value` contains the comment itself. Aside for empty strings, the fields in `EsINIState` will always point into the provided buffer.
For example, the line `[@hello world]` will set `sectionClass` to `"hello"`, `section` to `"world"`, and `key` and `value` to empty strings. When followed by the line `k=v`, `sectionClass` and `section` will retain their previous values, and `key` will be set to `"k"` and `value` will be set to `"v"`. For example, the line `[world]` will set `section` to `"world"`, and `key` and `value` to empty strings. When followed by the line `k=v`, `section` will retain its previous value, and `key` will be set to `"k"` and `value` will be set to `"v"`.
`EsINIFormat` formats the contents of `EsINIState` into a buffer. `bytes` gives the size of `buffer`. The return value gives the number of bytes written to `buffer`; this is clipped to the end of the buffer. `EsINIFormat` formats the contents of `EsINIState` into a buffer. `bytes` gives the size of `buffer`. The return value gives the number of bytes written to `buffer`; this is clipped to the end of the buffer.
`EsINIZeroTerminate` zero-terminates `sectionClass`, `section`, `key` and `value` in the `EsINIState`. It cannot be used after calling `EsINIPeek`. `EsINIZeroTerminate` zero-terminates `section`, `key` and `value` in the `EsINIState`. It cannot be used after calling `EsINIPeek`.
## Example ## Example

View File

@ -95,14 +95,14 @@ In the `[general]` section:
In the `[embed]` section there is a list of files that should be embedded into the application bundle. These embedded file can be accessed at runtime using the `EsBundleFind` API. The entries in this section are of the form `<embedded name>=<path>`. Embedded name prefixed with `$` are reserved for definition by the system. The ELF executable files are automatically embedded into the application's bundle, with names of the form `$Executables/<target>`. The application's icon should be embedded as PNG images with names of the form `$Icons/<size>`. You must, as a minimum, provide sizes `16` (16x16 pixels) and `32` (32x32 pixels). In the `[embed]` section there is a list of files that should be embedded into the application bundle. These embedded file can be accessed at runtime using the `EsBundleFind` API. The entries in this section are of the form `<embedded name>=<path>`. Embedded name prefixed with `$` are reserved for definition by the system. The ELF executable files are automatically embedded into the application's bundle, with names of the form `$Executables/<target>`. The application's icon should be embedded as PNG images with names of the form `$Icons/<size>`. You must, as a minimum, provide sizes `16` (16x16 pixels) and `32` (32x32 pixels).
Each `[@file_type]` section provides information about a file type. Each `[file_type]` section provides information about a file type.
- `extension` Gives the file name extension for the file type. - `extension` Gives the file name extension for the file type.
- `name` Gives the readable name of the file type, which will be shown to the user. TODO Translations. - `name` Gives the readable name of the file type, which will be shown to the user. TODO Translations.
- `icon` Gives the name of the icon from `desktop/icons.header` to show for files of this type. TODO Bundled icons. - `icon` Gives the name of the icon from `desktop/icons.header` to show for files of this type. TODO Bundled icons.
- `has_thumbnail_generator` Set to 1 if the file type has a thumbnail generator. Only images are supported at the moment. TODO Custom thumbnail generators. - `has_thumbnail_generator` Set to 1 if the file type has a thumbnail generator. Only images are supported at the moment. TODO Custom thumbnail generators.
Each `[@handler]` section describes this application's support to manage files of a given file type. Each `[handler]` section describes this application's support to manage files of a given file type.
- `extension` The file name extension of the file type. - `extension` The file name extension of the file type.
- `action` The action that this application support for the file type. Currently only "open" is supported. - `action` The action that this application support for the file type. Currently only "open" is supported.
@ -140,15 +140,15 @@ In the `[install]` section:
In the `[options]` section there is a copy of the options in "Configuration options", from `bin/config.ini`. Note that many of these options are not handled by build core, but rather by `util/build.c`. See the "Configuration options" section for more details. In the `[options]` section there is a copy of the options in "Configuration options", from `bin/config.ini`. Note that many of these options are not handled by build core, but rather by `util/build.c`. See the "Configuration options" section for more details.
Each `[@application]` section should contain a single key, `manifest`, giving the path to the application configuration options (see the above section). Each `[application]` section should contain a single key, `manifest`, giving the path to the application configuration options (see the above section).
Each `[@driver]` section should contain: Each `[driver]` section should contain:
- `name` The name of the driver. This must be found in `kernel/config.ini`. - `name` The name of the driver. This must be found in `kernel/config.ini`.
- `source` The source file of the driver. This must be C/C++. - `source` The source file of the driver. This must be C/C++.
- `builtin` Set to 1 if the driver should be linked directly into the kernel. Set to 0 if the driver should be built as a loadable module. - `builtin` Set to 1 if the driver should be linked directly into the kernel. Set to 0 if the driver should be built as a loadable module.
`[@font <name>]` sections specify the fonts that are to be bundled in the desktop executable. Each section should contain: `[font:<name>]` sections specify the fonts that are to be bundled in the desktop executable. Each section should contain:
- `category` One of `Sans`, `Serif` or `Mono`. More categories will likely be added in the future. - `category` One of `Sans`, `Serif` or `Mono`. More categories will likely be added in the future.
- `scripts` The scripts supported by the font. See `hb_script_t` in `bin/harfbuzz/src/hb-common.h` for a list of scripts. Separate each script with a `,`. - `scripts` The scripts supported by the font. See `hb_script_t` in `bin/harfbuzz/src/hb-common.h` for a list of scripts. Separate each script with a `,`.

View File

@ -1,49 +1,49 @@
[@driver Root] [driver:Root]
builtin=1 builtin=1
; Subsystems. ; Subsystems.
[@driver Networking] [driver:Networking]
parent=Root parent=Root
builtin=1 builtin=1
[@driver USB] [driver:USB]
source=drivers/usb.cpp source=drivers/usb.cpp
parent=Root parent=Root
builtin=1 builtin=1
; Architectures. ; Architectures.
[@driver ACPI] [driver:ACPI]
arch=x86_common arch=x86_common
parent=Root parent=Root
builtin=1 builtin=1
; Base devices. ; Base devices.
[@driver PCI] [driver:PCI]
source=drivers/pci.cpp source=drivers/pci.cpp
arch=x86_common arch=x86_common
builtin=1 builtin=1
[@driver SVGA] [driver:SVGA]
source=drivers/svga.cpp source=drivers/svga.cpp
arch=x86_common arch=x86_common
builtin=1 builtin=1
[@driver PS2] [driver:PS2]
source=drivers/ps2.cpp source=drivers/ps2.cpp
arch=x86_common arch=x86_common
builtin=1 builtin=1
[@driver RTC] [driver:RTC]
source=drivers/rtc.cpp source=drivers/rtc.cpp
arch=x86_common arch=x86_common
builtin=1 builtin=1
; PCI devices. ; PCI devices.
[@driver IDE] [driver:IDE]
source=drivers/ide.cpp source=drivers/ide.cpp
builtin=1 builtin=1
arch=x86_common arch=x86_common
@ -51,14 +51,14 @@ parent=PCI
classCode=0x01 classCode=0x01
subclassCode=0x01 subclassCode=0x01
[@driver AHCI] [driver:AHCI]
source=drivers/ahci.cpp source=drivers/ahci.cpp
builtin=1 builtin=1
parent=PCI parent=PCI
classCode=0x01 classCode=0x01
subclassCode=0x06 subclassCode=0x06
[@driver NVMe] [driver:NVMe]
source=drivers/nvme.cpp source=drivers/nvme.cpp
builtin=1 builtin=1
parent=PCI parent=PCI
@ -66,7 +66,7 @@ classCode=0x01
subclassCode=0x08 subclassCode=0x08
progIF=0x02 progIF=0x02
[@driver HDAudio] [driver:HDAudio]
name=HDAudio name=HDAudio
source=drivers/hda.cpp source=drivers/hda.cpp
builtin=1 builtin=1
@ -74,7 +74,7 @@ parent=PCI
classCode=0x04 classCode=0x04
subclassCode=0x03 subclassCode=0x03
[@driver xHCI] [driver:xHCI]
source=drivers/xhci.cpp source=drivers/xhci.cpp
builtin=1 builtin=1
parent=PCI parent=PCI
@ -82,14 +82,14 @@ classCode=0x0C
subclassCode=0x03 subclassCode=0x03
progIF=0x30 progIF=0x30
[@driver BGA] [driver:BGA]
source=drivers/bga.cpp source=drivers/bga.cpp
builtin=1 builtin=1
parent=PCI parent=PCI
deviceID=0xBEEF80EE deviceID=0xBEEF80EE
deviceID=0x11111234 deviceID=0x11111234
[@driver I8254x] [driver:I8254x]
source=drivers/i8254x.cpp source=drivers/i8254x.cpp
builtin=1 builtin=1
parent=PCI parent=PCI
@ -97,13 +97,13 @@ deviceID=0x100E8086
; USB devices. ; USB devices.
[@driver USBHID] [driver:USBHID]
source=drivers/usb_hid.cpp source=drivers/usb_hid.cpp
builtin=1 builtin=1
parent=USB parent=USB
classCode=0x03 classCode=0x03
[@driver USBBulk] [driver:USBBulk]
source=drivers/usb_bulk.cpp source=drivers/usb_bulk.cpp
builtin=1 builtin=1
parent=USB parent=USB
@ -113,14 +113,14 @@ protocol=0x50
; File systems. ; File systems.
[@driver EssenceFS] [driver:EssenceFS]
source=drivers/esfs2.cpp source=drivers/esfs2.cpp
builtin=1 builtin=1
parent=Files parent=Files
signature_offset=0x2000 signature_offset=0x2000
signature=!EssenceFS2----- signature=!EssenceFS2-----
[@driver FAT] [driver:FAT]
source=drivers/fat.cpp source=drivers/fat.cpp
builtin=1 builtin=1
parent=Files parent=Files
@ -129,21 +129,21 @@ signature=)
signature_offset=0x42 signature_offset=0x42
signature=) signature=)
[@driver ISO9660] [driver:ISO9660]
source=drivers/iso9660.cpp source=drivers/iso9660.cpp
builtin=1 builtin=1
parent=Files parent=Files
signature_offset=0x8001 signature_offset=0x8001
signature=CD001 signature=CD001
[@driver NTFS] [driver:NTFS]
source=drivers/ntfs.cpp source=drivers/ntfs.cpp
builtin=1 builtin=1
parent=Files parent=Files
signature_offset=3 signature_offset=3
signature=NTFS signature=NTFS
[@driver Ext2] [driver:Ext2]
source=drivers/ext2.cpp source=drivers/ext2.cpp
builtin=1 builtin=1
parent=Files parent=Files
@ -152,6 +152,6 @@ signature=S
; ACPI devices. ; ACPI devices.
[@driver ACPIThermal] [driver:ACPIThermal]
source=drivers/acpi_thermal.cpp source=drivers/acpi_thermal.cpp
builtin=1 builtin=1

View File

@ -8,11 +8,11 @@ hidden=1
custom_compile_command=cp root/Applications/POSIX/bin/bochs bin/Bochs custom_compile_command=cp root/Applications/POSIX/bin/bochs bin/Bochs
require=root/Applications/POSIX/bin/bochs require=root/Applications/POSIX/bin/bochs
[@file_type] [file_type]
extension=bochsrc extension=bochsrc
name=Bochs configuration name=Bochs configuration
icon=icon_applications_development icon=icon_applications_development
[@handler] [handler]
extension=bochsrc extension=bochsrc
action=open action=open

View File

@ -9,11 +9,11 @@ link_flags=-lOSMesa -lstdc++ -lz
with_cstdlib=1 with_cstdlib=1
source=ports/mesa/obj_viewer.c source=ports/mesa/obj_viewer.c
[@handler] [handler]
extension=obj extension=obj
action=open action=open
[@file_type] [file_type]
extension=obj extension=obj
name=3D model name=3D model
icon=icon_model icon=icon_model

View File

@ -6,11 +6,11 @@ hidden=1
source=ports/uxn/emulator.c source=ports/uxn/emulator.c
compile_flags=-Wno-unknown-pragmas -Wno-unused-parameter compile_flags=-Wno-unknown-pragmas -Wno-unused-parameter
[@handler] [handler]
extension=uxn extension=uxn
action=open action=open
[@file_type] [file_type]
extension=uxn extension=uxn
name=Uxn ROM name=Uxn ROM
icon=icon_unknown icon=icon_unknown

View File

@ -14,14 +14,8 @@ bool EsINIParse(EsINIState *s) {
s->valueBytes = 0; s->valueBytes = 0;
INI_READ(key, keyBytes, '\n', 0); INI_READ(key, keyBytes, '\n', 0);
} else if (c == '[') { } else if (c == '[') {
s->sectionClassBytes = s->keyBytes = s->valueBytes = 0; s->keyBytes = s->valueBytes = 0;
s->buffer++, s->bytes--; s->buffer++, s->bytes--;
if (s->bytes && *s->buffer == '@') {
s->buffer++, s->bytes--;
INI_READ(sectionClass, sectionClassBytes, ' ', ']');
}
INI_READ(section, sectionBytes, ']', 0); INI_READ(section, sectionBytes, ']', 0);
} else { } else {
INI_READ(key, keyBytes, '=', '\n'); INI_READ(key, keyBytes, '=', '\n');
@ -56,9 +50,6 @@ size_t EsINIFormat(EsINIState *s, char *buffer, size_t bytes) {
INI_WRITE("\n", 1); INI_WRITE("\n", 1);
} else { } else {
INI_WRITE("\n[", 2); INI_WRITE("\n[", 2);
if (s->sectionClassBytes) INI_WRITE("@", 1);
INI_WRITE(s->sectionClass, s->sectionClassBytes);
if (s->sectionClassBytes && s->sectionBytes) INI_WRITE(" ", 1);
INI_WRITE(s->section, s->sectionBytes); INI_WRITE(s->section, s->sectionBytes);
INI_WRITE("]\n", 2); INI_WRITE("]\n", 2);
} }
@ -68,7 +59,6 @@ size_t EsINIFormat(EsINIState *s, char *buffer, size_t bytes) {
void EsINIZeroTerminate(EsINIState *s) { void EsINIZeroTerminate(EsINIState *s) {
static char emptyString = 0; static char emptyString = 0;
if (s->sectionClassBytes) s->sectionClass[s->sectionClassBytes] = 0; else s->sectionClass = &emptyString;
if (s->sectionBytes) s->section[s->sectionBytes] = 0; else s->section = &emptyString; if (s->sectionBytes) s->section[s->sectionBytes] = 0; else s->section = &emptyString;
if (s->keyBytes) s->key[s->keyBytes] = 0; else s->key = &emptyString; if (s->keyBytes) s->key[s->keyBytes] = 0; else s->key = &emptyString;
if (s->valueBytes) s->value[s->valueBytes] = 0; else s->value = &emptyString; if (s->valueBytes) s->value[s->valueBytes] = 0; else s->value = &emptyString;

View File

@ -287,18 +287,18 @@ void Compile(uint32_t flags, int partitionSize, const char *volumeLabel) {
while (EsINIParse(&s)) { while (EsINIParse(&s)) {
EsINIZeroTerminate(&s); EsINIZeroTerminate(&s);
if (strcmp(s.sectionClass, "driver")) { if (memcmp(s.section, "driver:", 7)) {
continue; continue;
} }
name = s.section; name = s.section + 7;
if (0 == strcmp(s.key, "source")) source = s.value; if (0 == strcmp(s.key, "source")) source = s.value;
if (0 == strcmp(s.key, "builtin")) builtin = !!atoi(s.value); if (0 == strcmp(s.key, "builtin")) builtin = !!atoi(s.value);
if (!EsINIPeek(&s) || !s.keyBytes) { if (!EsINIPeek(&s) || !s.keyBytes) {
if (IsDriverEnabled(name)) { if (IsDriverEnabled(name)) {
fprintf(f, "[@driver]\nname=%s\nsource=%s\nbuiltin=%d\n\n", name, source ?: "", builtin); fprintf(f, "[driver]\nname=%s\nsource=%s\nbuiltin=%d\n\n", name, source ?: "", builtin);
} }
source = name = NULL; source = name = NULL;
@ -336,7 +336,7 @@ void Compile(uint32_t flags, int partitionSize, const char *volumeLabel) {
continue; continue;
} }
fprintf(f, "[@font %s]\ncategory=%s\nscripts=%s\nlicense=%s\n", font->name, font->category, font->scripts, font->license); fprintf(f, "[font:%s]\ncategory=%s\nscripts=%s\nlicense=%s\n", font->name, font->category, font->scripts, font->license);
fileIndex = 0; fileIndex = 0;
while (font->files[fileIndex].path) { while (font->files[fileIndex].path) {
@ -360,7 +360,7 @@ void Compile(uint32_t flags, int partitionSize, const char *volumeLabel) {
continue; continue;
} }
fprintf(f, "[@application]\nmanifest=apps/%s\n\n", entry->d_name); fprintf(f, "[application]\nmanifest=apps/%s\n\n", entry->d_name);
} }
closedir(root); closedir(root);
@ -369,7 +369,7 @@ void Compile(uint32_t flags, int partitionSize, const char *volumeLabel) {
while (s.buffer && EsINIParse(&s)) { while (s.buffer && EsINIParse(&s)) {
if (!s.keyBytes || s.valueBytes || (s.keyBytes >= 1 && s.key[0] == ';')) continue; if (!s.keyBytes || s.valueBytes || (s.keyBytes >= 1 && s.key[0] == ';')) continue;
fprintf(f, "[@application]\nmanifest=%.*s\n\n", (int) s.keyBytes, s.key); fprintf(f, "[application]\nmanifest=%.*s\n\n", (int) s.keyBytes, s.key);
} }
} }
@ -1576,7 +1576,7 @@ int main(int _argc, char **_argv) {
path[0] = 0; path[0] = 0;
while (EsINIParse(&s)) { while (EsINIParse(&s)) {
if (s.sectionClassBytes || s.sectionBytes) continue; if (s.sectionBytes) continue;
EsINIZeroTerminate(&s); EsINIZeroTerminate(&s);
INI_READ_BOOL(accepted_license, acceptedLicense); INI_READ_BOOL(accepted_license, acceptedLicense);

View File

@ -12,8 +12,8 @@
#include <stdlib.h> #include <stdlib.h>
typedef struct EsINIState { typedef struct EsINIState {
char *buffer, *sectionClass, *section, *key, *value; char *buffer, *section, *key, *value;
size_t bytes, sectionClassBytes, sectionBytes, keyBytes, valueBytes; size_t bytes, sectionBytes, keyBytes, valueBytes;
} EsINIState; } EsINIState;
#include "../shared/ini.h" #include "../shared/ini.h"

View File

@ -815,7 +815,7 @@ void ParseApplicationManifest(const char *manifestPath) {
else INI_READ_BOOL(disabled, disabled); else INI_READ_BOOL(disabled, disabled);
else INI_READ_BOOL(needs_native_toolchain, needsNativeToolchain); else INI_READ_BOOL(needs_native_toolchain, needsNativeToolchain);
else if (s.keyBytes && s.valueBytes) arrput(application.properties, s); else if (s.keyBytes && s.valueBytes) arrput(application.properties, s);
} else if (0 == strcmp(s.sectionClass, "handler")) { } else if (0 == strcmp(s.section, "handler")) {
if (!s.keyBytes) { if (!s.keyBytes) {
Handler _handler = {}; Handler _handler = {};
arrput(application.handlers, _handler); arrput(application.handlers, _handler);
@ -824,7 +824,7 @@ void ParseApplicationManifest(const char *manifestPath) {
INI_READ_STRING_PTR(extension, handler->extension); INI_READ_STRING_PTR(extension, handler->extension);
INI_READ_STRING_PTR(action, handler->action); INI_READ_STRING_PTR(action, handler->action);
} else if (0 == strcmp(s.sectionClass, "file_type")) { } else if (0 == strcmp(s.section, "file_type")) {
if (!s.keyBytes) { if (!s.keyBytes) {
FileType _fileType = {}; FileType _fileType = {};
_fileType.id = nextID++; _fileType.id = nextID++;
@ -921,7 +921,8 @@ void OutputSystemConfiguration() {
continue; continue;
} }
FilePrintFormat(file, "\n[@application %d]\n", applications[i].id); FilePrintFormat(file, "\n[application]\n");
FilePrintFormat(file, "id=%d\n", applications[i].id);
FilePrintFormat(file, "name=%s\n", applications[i].name); FilePrintFormat(file, "name=%s\n", applications[i].name);
FilePrintFormat(file, "executable=0:/Applications/%s.esx\n", applications[i].name); FilePrintFormat(file, "executable=0:/Applications/%s.esx\n", applications[i].name);
FilePrintFormat(file, "settings_path=0:/" SYSTEM_FOLDER_NAME "/Settings/%s\n", applications[i].name); FilePrintFormat(file, "settings_path=0:/" SYSTEM_FOLDER_NAME "/Settings/%s\n", applications[i].name);
@ -931,7 +932,8 @@ void OutputSystemConfiguration() {
} }
for (uintptr_t j = 0; j < arrlenu(applications[i].fileTypes); j++) { for (uintptr_t j = 0; j < arrlenu(applications[i].fileTypes); j++) {
FilePrintFormat(file, "\n[@file_type %d]\n", applications[i].fileTypes[j].id); FilePrintFormat(file, "\n[file_type]\n");
FilePrintFormat(file, "id=%d\n", applications[i].fileTypes[j].id);
FilePrintFormat(file, "extension=%s\n", applications[i].fileTypes[j].extension); FilePrintFormat(file, "extension=%s\n", applications[i].fileTypes[j].extension);
FilePrintFormat(file, "name=%s\n", applications[i].fileTypes[j].name); FilePrintFormat(file, "name=%s\n", applications[i].fileTypes[j].name);
FilePrintFormat(file, "icon=%s\n", applications[i].fileTypes[j].icon); FilePrintFormat(file, "icon=%s\n", applications[i].fileTypes[j].icon);
@ -940,7 +942,7 @@ void OutputSystemConfiguration() {
} }
for (uintptr_t j = 0; j < arrlenu(applications[i].handlers); j++) { for (uintptr_t j = 0; j < arrlenu(applications[i].handlers); j++) {
FilePrintFormat(file, "\n[@handler]\n"); FilePrintFormat(file, "\n[handler]\n");
FilePrintFormat(file, "action=%s\n", applications[i].handlers[j].action); FilePrintFormat(file, "action=%s\n", applications[i].handlers[j].action);
FilePrintFormat(file, "application=%d\n", applications[i].id); FilePrintFormat(file, "application=%d\n", applications[i].id);
FilePrintFormat(file, "file_type=%d\n", applications[i].handlers[j].fileTypeID); FilePrintFormat(file, "file_type=%d\n", applications[i].handlers[j].fileTypeID);
@ -1008,13 +1010,13 @@ void ParseKernelConfiguration() {
EsINIState previous = s; EsINIState previous = s;
while (EsINIParse(&s)) { while (EsINIParse(&s)) {
if (!IsStringEqual(s.sectionClass, s.sectionClassBytes, "driver") if (!(s.sectionBytes > 7 && 0 == memcmp(s.section, "driver:", 7))
|| (previous.sectionBytes == s.sectionBytes && 0 == memcmp(previous.section, s.section, s.sectionBytes)) || (previous.sectionBytes == s.sectionBytes && 0 == memcmp(previous.section, s.section, s.sectionBytes))
|| !IsModuleEnabled(s.section, s.sectionBytes)) { || !IsModuleEnabled(s.section + 7, s.sectionBytes - 7)) {
continue; continue;
} }
FilePrintFormat(f, "extern \"C\" KDriver driver%.*s;\n", (int) s.sectionBytes, s.section); FilePrintFormat(f, "extern \"C\" KDriver driver%.*s;\n", (int) s.sectionBytes - 7, s.section + 7);
previous = s; previous = s;
} }
@ -1030,12 +1032,12 @@ void ParseKernelConfiguration() {
bool foundMatchingArchitecture = false, anyArchitecturesListed = false; bool foundMatchingArchitecture = false, anyArchitecturesListed = false;
while (EsINIParse(&s)) { while (EsINIParse(&s)) {
if (!IsStringEqual(s.sectionClass, s.sectionClassBytes, "driver")) { if (!(s.sectionBytes > 7 && 0 == memcmp(s.section, "driver:", 7))) {
continue; continue;
} }
moduleName = s.section; moduleName = s.section + 7;
moduleNameBytes = s.sectionBytes; moduleNameBytes = s.sectionBytes - 7;
if (IsStringEqual(s.key, s.keyBytes, "parent")) { if (IsStringEqual(s.key, s.keyBytes, "parent")) {
parentName = s.value, parentNameBytes = s.valueBytes; parentName = s.value, parentNameBytes = s.valueBytes;
@ -1364,7 +1366,7 @@ int main(int argc, char **argv) {
} else if (0 == strcmp(s.key, "compiler_objects")) { } else if (0 == strcmp(s.key, "compiler_objects")) {
toolchainCompilerObjects = s.value; toolchainCompilerObjects = s.value;
} }
} else if (0 == strcmp(s.sectionClass, "application")) { } else if (0 == strcmp(s.section, "application")) {
if (0 == strcmp(s.key, "manifest")) { if (0 == strcmp(s.key, "manifest")) {
arrput(applicationManifests, s.value); arrput(applicationManifests, s.value);
} }
@ -1467,9 +1469,9 @@ int main(int argc, char **argv) {
} else if (0 == strcmp(s.key, "partition_size")) { } else if (0 == strcmp(s.key, "partition_size")) {
partitionSize = atoi(s.value) * 1048576UL; partitionSize = atoi(s.value) * 1048576UL;
} }
} else if (0 == strcmp(s.sectionClass, "font")) { } else if (0 == memcmp(s.section, "font:", 5)) {
arrput(fontLines, s); arrput(fontLines, s);
} else if (0 == strcmp(s.sectionClass, "driver")) { } else if (0 == strcmp(s.section, "driver")) {
if (0 == strcmp(s.key, "name")) driverName = s.value; if (0 == strcmp(s.key, "name")) driverName = s.value;
if (0 == strcmp(s.key, "source")) driverSource = s.value; if (0 == strcmp(s.key, "source")) driverSource = s.value;
if (0 == strcmp(s.key, "builtin")) driverBuiltin = !!atoi(s.value); if (0 == strcmp(s.key, "builtin")) driverBuiltin = !!atoi(s.value);
@ -1505,7 +1507,6 @@ int main(int argc, char **argv) {
} }
if (0 != strcmp(s.section, "install")) { if (0 != strcmp(s.section, "install")) {
configurationHash = CalculateCRC64(s.sectionClass, s.sectionClassBytes, configurationHash);
configurationHash = CalculateCRC64(s.section, s.sectionBytes, configurationHash); configurationHash = CalculateCRC64(s.section, s.sectionBytes, configurationHash);
configurationHash = CalculateCRC64(s.key, s.keyBytes, configurationHash); configurationHash = CalculateCRC64(s.key, s.keyBytes, configurationHash);
configurationHash = CalculateCRC64(s.value, s.valueBytes, configurationHash); configurationHash = CalculateCRC64(s.value, s.valueBytes, configurationHash);
@ -1861,8 +1862,7 @@ void CommandLaunch(EsInstance *instance, EsElement *element, EsCommand *command)
size_t executablePathBytes = 0; size_t executablePathBytes = 0;
while (EsINIParse(&s)) { while (EsINIParse(&s)) {
if (s.sectionClassBytes == 0 if (0 == EsStringCompareRaw(s.section, s.sectionBytes, EsLiteral("general"))
&& 0 == EsStringCompareRaw(s.section, s.sectionBytes, EsLiteral("general"))
&& 0 == EsStringCompareRaw(s.key, s.keyBytes, EsLiteral("name"))) { && 0 == EsStringCompareRaw(s.key, s.keyBytes, EsLiteral("name"))) {
executablePath = EsStringAllocateAndFormat(&executablePathBytes, "%s/bin/%s.esx", workingDirectoryBytes, workingDirectory, s.valueBytes, s.value); executablePath = EsStringAllocateAndFormat(&executablePathBytes, "%s/bin/%s.esx", workingDirectoryBytes, workingDirectory, s.valueBytes, s.value);
} }

View File

@ -8,11 +8,11 @@ permission_run_temporary_application=1
[build] [build]
source=util/build_core.c source=util/build_core.c
[@file_type] [file_type]
extension=build_core extension=build_core
name=Build config name=Build config
icon=icon_text_x_makefile icon=icon_text_x_makefile
[@handler] [handler]
extension=build_core extension=build_core
action=open action=open

View File

@ -3753,6 +3753,25 @@ int WindowMessage(UIElement *element, UIMessage message, int di, void *dp) {
void DocumentFileMenu(void *) { void DocumentFileMenu(void *) {
EsFileMenuCreate(ui.instance, ui.instance->window, ES_MENU_AT_CURSOR); EsFileMenuCreate(ui.instance, ui.instance->window, ES_MENU_AT_CURSOR);
} }
int _UIInstanceCallback(EsInstance *instance, EsMessage *message) {
if (message->type == ES_MSG_INSTANCE_SAVE) {
fileStore = message->instanceSave.file;
DocumentSave(nullptr);
EsInstanceSaveComplete(instance, fileStore, true);
fileStore = nullptr;
} else if (message->type == ES_MSG_INSTANCE_OPEN) {
DocumentFree();
fileStore = message->instanceOpen.file;
DocumentLoad();
EsInstanceOpenComplete(instance, fileStore, true);
fileStore = nullptr;
} else {
return 0;
}
return ES_HANDLED;
}
#endif #endif
void DocumentMenu(void *) { void DocumentMenu(void *) {
@ -3781,6 +3800,11 @@ int main(int argc, char **argv) {
#endif #endif
UIInitialise(); UIInitialise();
#ifdef OS_ESSENCE
ui.instance->callback = _UIInstanceCallback;
#endif
ui.theme = _uiThemeClassic; ui.theme = _uiThemeClassic;
window = UIWindowCreate(0, UI_ELEMENT_PARENT_PUSH | UI_WINDOW_MAXIMIZE, "Designer", 0, 0); window = UIWindowCreate(0, UI_ELEMENT_PARENT_PUSH | UI_WINDOW_MAXIMIZE, "Designer", 0, 0);
window->e.messageUser = WindowMessage; window->e.messageUser = WindowMessage;
@ -3850,25 +3874,6 @@ int main(int argc, char **argv) {
#ifdef OS_ESSENCE #ifdef OS_ESSENCE
void _UIMessageProcess(EsMessage *message) {} void _UIMessageProcess(EsMessage *message) {}
int _UIInstanceCallback(EsInstance *instance, EsMessage *message) {
if (message->type == ES_MSG_INSTANCE_SAVE) {
fileStore = message->instanceSave.file;
DocumentSave(nullptr);
EsInstanceSaveComplete(instance, fileStore, true);
fileStore = nullptr;
} else if (message->type == ES_MSG_INSTANCE_OPEN) {
DocumentFree();
fileStore = message->instanceOpen.file;
DocumentLoad();
EsInstanceOpenComplete(instance, fileStore, true);
fileStore = nullptr;
} else {
return 0;
}
return ES_HANDLED;
}
void _start() { void _start() {
_init(); _init();
main(0, nullptr); main(0, nullptr);

View File

@ -6,11 +6,11 @@ icon=icon_applications_interfacedesign
source=util/designer2.cpp source=util/designer2.cpp
compile_flags=-D UI_ESSENCE -Wno-unused-parameter compile_flags=-D UI_ESSENCE -Wno-unused-parameter
[@file_type] [file_type]
extension=designer extension=designer
name=Designer file name=Designer file
icon=icon_text_css icon=icon_text_css
[@handler] [handler]
extension=designer extension=designer
action=open action=open