fix text/image preview loading

Mon, 11 Nov 2024 20:45:34 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Mon, 11 Nov 2024 20:45:34 +0100
changeset 77
5de33c2d94c6
parent 76
641dcc79e0ef
child 78
ad7ced6cf00b

fix text/image preview loading

application/davcontroller.c file | annotate | diff | comparison | revisions
application/window.c file | annotate | diff | comparison | revisions
make/vs/idav.sln file | annotate | diff | comparison | revisions
make/vs/idav/idav.vcxproj file | annotate | diff | comparison | revisions
make/vs/idav/idav.vcxproj.filters file | annotate | diff | comparison | revisions
make/vs/idav/x64/Debug/idav.exe.recipe file | annotate | diff | comparison | revisions
make/vs/idav/x64/Debug/idav.ilk file | annotate | diff | comparison | revisions
make/vs/idav/x64/Debug/idav.log file | annotate | diff | comparison | revisions
make/vs/idav/x64/Debug/idav.tlog/CL.command.1.tlog file | annotate | diff | comparison | revisions
make/vs/idav/x64/Debug/idav.tlog/CL.read.1.tlog file | annotate | diff | comparison | revisions
make/vs/idav/x64/Debug/idav.tlog/CL.write.1.tlog file | annotate | diff | comparison | revisions
make/vs/idav/x64/Debug/idav.tlog/Cl.items.tlog file | annotate | diff | comparison | revisions
make/vs/idav/x64/Debug/idav.tlog/CopyLocal.read.1u.tlog file | annotate | diff | comparison | revisions
make/vs/idav/x64/Debug/idav.tlog/CopyLocal.write.1u.tlog file | annotate | diff | comparison | revisions
make/vs/idav/x64/Debug/idav.tlog/idav.lastbuildstate file | annotate | diff | comparison | revisions
make/vs/idav/x64/Debug/idav.tlog/link.command.1.tlog file | annotate | diff | comparison | revisions
make/vs/idav/x64/Debug/idav.tlog/link.read.1.tlog file | annotate | diff | comparison | revisions
make/vs/idav/x64/Debug/idav.tlog/link.write.1.tlog file | annotate | diff | comparison | revisions
make/vs/idav/x64/Debug/idav.vcxproj.AssemblyReference.cache file | annotate | diff | comparison | revisions
make/vs/idav/x64/Debug/idav.vcxproj.CopyComplete file | annotate | diff | comparison | revisions
make/vs/idav/x64/Debug/idav.vcxproj.FileListAbsolute.txt file | annotate | diff | comparison | revisions
make/vs/idav/x64/Debug/main.obj file | annotate | diff | comparison | revisions
make/vs/idav/x64/Debug/vc143.idb file | annotate | diff | comparison | revisions
make/vs/idav/x64/Debug/vc143.pdb file | annotate | diff | comparison | revisions
make/vs/idav/x64/Debug/vcpkg.applocal.log file | annotate | diff | comparison | revisions
make/vs/libidav/libidav.vcxproj file | annotate | diff | comparison | revisions
make/vs/libidav/libidav.vcxproj.filters file | annotate | diff | comparison | revisions
ucx/cx/map.h file | annotate | diff | comparison | revisions
ui/common/context.c file | annotate | diff | comparison | revisions
ui/common/document.c file | annotate | diff | comparison | revisions
ui/common/menu.c file | annotate | diff | comparison | revisions
ui/common/properties.c file | annotate | diff | comparison | revisions
ui/ui/properties.h file | annotate | diff | comparison | revisions
ui/winui/text.cpp file | annotate | diff | comparison | revisions
ui/winui/text.h file | annotate | diff | comparison | revisions
ui/winui/toolkit.cpp file | annotate | diff | comparison | revisions
ui/winui/winui.vcxproj file | annotate | diff | comparison | revisions
ui/winui/winui.vcxproj.filters file | annotate | diff | comparison | revisions
--- a/application/davcontroller.c	Sun Nov 10 15:30:46 2024 +0100
+++ b/application/davcontroller.c	Mon Nov 11 20:45:34 2024 +0100
@@ -882,7 +882,7 @@
     file->download->current_file_downloaded = 0;
     file->download->current_file_size = file->size;
 
-    FILE *f = fopen(file->to, "wb");
+    FILE *f = sys_fopen(file->to, "wb");
     if (!f) {
         return 0;
     }
@@ -1299,7 +1299,7 @@
     memset(rd, 0, 8);
     dav_rand_bytes(rd, 8);   
     char *hex = util_hexstr(rd, 8);
-    cxmutstr tmp = cx_asprintf("%sdownload-%s-%s", dir, name, hex);
+    cxmutstr tmp = cx_asprintf("%sdownload-%s-%s", dir, hex, name);
     return tmp.ptr;
 }
 
@@ -1322,7 +1322,7 @@
                 }
             } else if(doc->type == DAV_RESOURCE_VIEW_IMAGE) {
                 char *tmp = gen_tmp_download_filename(res->name);
-                FILE *f = fopen(tmp, "w");
+                FILE *f = sys_fopen(tmp, "wb");
                 if(f) {
                     int err = dav_get_content(res, f, (dav_write_func)fwrite);
                     if(!err) {
@@ -1447,7 +1447,6 @@
         ui_set(doc->text, doc->text_content->space);
     } else if(doc->type == DAV_RESOURCE_VIEW_IMAGE) {
         ui_image_load_file(doc->image, doc->tmp_file);
-        unlink(doc->tmp_file);
     }
       
     ui_set(doc->tabview, 1);
--- a/application/window.c	Sun Nov 10 15:30:46 2024 +0100
+++ b/application/window.c	Mon Nov 11 20:45:34 2024 +0100
@@ -117,11 +117,17 @@
     if(doc->loaded) {
         dav_resourceviewer_destroy(doc);
     }
+
+    if (doc->tmp_file) {
+        unlink(doc->tmp_file);
+        free(doc->tmp_file);
+    }
 }
 
 void resourceviewer_new(DavBrowser *browser, const char *path, DavResourceViewType type) {
     const char *name = util_resource_name(path);
     UiObject *win = ui_simple_window(name, NULL);
+    ui_window_size(win, 600, 600);
     
     DavResourceViewer *doc = dav_resourceviewer_create(browser->sn, path, type);
     ui_attach_document(win->ctx, doc);
--- a/make/vs/idav.sln	Sun Nov 10 15:30:46 2024 +0100
+++ b/make/vs/idav.sln	Mon Nov 11 20:45:34 2024 +0100
@@ -9,8 +9,6 @@
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "winui", "..\..\ui\winui\winui.vcxproj", "{59F97886-BF49-4B3F-9EF6-FA7A84F3AB56}"
 EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "uicommon", "uicommon\uicommon.vcxproj", "{8B88698E-C185-4383-99FE-0C34D6DEED2E}"
-EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "idav", "idav\idav.vcxproj", "{F975D652-779E-4945-BFC2-8C649C6F9938}"
 EndProject
 Global
@@ -65,18 +63,6 @@
 		{59F97886-BF49-4B3F-9EF6-FA7A84F3AB56}.Release|x86.ActiveCfg = Release|Win32
 		{59F97886-BF49-4B3F-9EF6-FA7A84F3AB56}.Release|x86.Build.0 = Release|Win32
 		{59F97886-BF49-4B3F-9EF6-FA7A84F3AB56}.Release|x86.Deploy.0 = Release|Win32
-		{8B88698E-C185-4383-99FE-0C34D6DEED2E}.Debug|ARM64.ActiveCfg = Debug|x64
-		{8B88698E-C185-4383-99FE-0C34D6DEED2E}.Debug|ARM64.Build.0 = Debug|x64
-		{8B88698E-C185-4383-99FE-0C34D6DEED2E}.Debug|x64.ActiveCfg = Debug|x64
-		{8B88698E-C185-4383-99FE-0C34D6DEED2E}.Debug|x64.Build.0 = Debug|x64
-		{8B88698E-C185-4383-99FE-0C34D6DEED2E}.Debug|x86.ActiveCfg = Debug|Win32
-		{8B88698E-C185-4383-99FE-0C34D6DEED2E}.Debug|x86.Build.0 = Debug|Win32
-		{8B88698E-C185-4383-99FE-0C34D6DEED2E}.Release|ARM64.ActiveCfg = Release|x64
-		{8B88698E-C185-4383-99FE-0C34D6DEED2E}.Release|ARM64.Build.0 = Release|x64
-		{8B88698E-C185-4383-99FE-0C34D6DEED2E}.Release|x64.ActiveCfg = Release|x64
-		{8B88698E-C185-4383-99FE-0C34D6DEED2E}.Release|x64.Build.0 = Release|x64
-		{8B88698E-C185-4383-99FE-0C34D6DEED2E}.Release|x86.ActiveCfg = Release|Win32
-		{8B88698E-C185-4383-99FE-0C34D6DEED2E}.Release|x86.Build.0 = Release|Win32
 		{F975D652-779E-4945-BFC2-8C649C6F9938}.Debug|ARM64.ActiveCfg = Debug|x64
 		{F975D652-779E-4945-BFC2-8C649C6F9938}.Debug|ARM64.Build.0 = Debug|x64
 		{F975D652-779E-4945-BFC2-8C649C6F9938}.Debug|x64.ActiveCfg = Debug|x64
--- a/make/vs/idav/idav.vcxproj	Sun Nov 10 15:30:46 2024 +0100
+++ b/make/vs/idav/idav.vcxproj	Mon Nov 11 20:45:34 2024 +0100
@@ -164,7 +164,7 @@
     <ClCompile Include="..\..\..\application\config.c" />
     <ClCompile Include="..\..\..\application\davcontroller.c" />
     <ClCompile Include="..\..\..\application\main.c" />
-    <ClCompile Include="..\..\..\application\pwd.c" />
+    <ClCompile Include="..\..\..\application\settings.c" />
     <ClCompile Include="..\..\..\application\system.c" />
     <ClCompile Include="..\..\..\application\window.c" />
   </ItemGroup>
@@ -172,7 +172,7 @@
     <ClInclude Include="..\..\..\application\application.h" />
     <ClInclude Include="..\..\..\application\config.h" />
     <ClInclude Include="..\..\..\application\davcontroller.h" />
-    <ClInclude Include="..\..\..\application\pwd.h" />
+    <ClInclude Include="..\..\..\application\settings.h" />
     <ClInclude Include="..\..\..\application\system.h" />
     <ClInclude Include="..\..\..\application\window.h" />
   </ItemGroup>
--- a/make/vs/idav/idav.vcxproj.filters	Sun Nov 10 15:30:46 2024 +0100
+++ b/make/vs/idav/idav.vcxproj.filters	Mon Nov 11 20:45:34 2024 +0100
@@ -34,10 +34,10 @@
     <ClCompile Include="..\..\..\application\system.c">
       <Filter>src</Filter>
     </ClCompile>
-    <ClCompile Include="..\..\..\application\pwd.c">
+    <ClCompile Include="..\..\..\application\davcontroller.c">
       <Filter>src</Filter>
     </ClCompile>
-    <ClCompile Include="..\..\..\application\davcontroller.c">
+    <ClCompile Include="..\..\..\application\settings.c">
       <Filter>src</Filter>
     </ClCompile>
   </ItemGroup>
@@ -54,10 +54,10 @@
     <ClInclude Include="..\..\..\application\system.h">
       <Filter>src</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\..\application\pwd.h">
+    <ClInclude Include="..\..\..\application\davcontroller.h">
       <Filter>src</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\..\application\davcontroller.h">
+    <ClInclude Include="..\..\..\application\settings.h">
       <Filter>src</Filter>
     </ClInclude>
   </ItemGroup>
--- a/make/vs/idav/x64/Debug/idav.exe.recipe	Sun Nov 10 15:30:46 2024 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project>
-  <ProjectOutputs>
-    <ProjectOutput>
-      <FullPath>C:\Users\Olaf\Projekte\idav\make\vs\x64\Debug\idav.exe</FullPath>
-    </ProjectOutput>
-  </ProjectOutputs>
-  <ContentFiles />
-  <SatelliteDlls />
-  <NonRecipeFileRefs />
-</Project>
\ No newline at end of file
Binary file make/vs/idav/x64/Debug/idav.ilk has changed
--- a/make/vs/idav/x64/Debug/idav.log	Sun Nov 10 15:30:46 2024 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,4 +0,0 @@
-  main.c
-  idav.vcxproj -> C:\Users\Olaf\Projekte\idav\make\vs\x64\Debug\idav.exe
-  C:\Users\Olaf\Projekte\idav\make\vs\packages\Microsoft.WindowsAppSDK.1.3.230331000\build\native\..\..\runtimes\win10-x64\native\Microsoft.WindowsAppRuntime.Bootstrap.dll
-  1 Datei(en) kopiert
Binary file make/vs/idav/x64/Debug/idav.tlog/CL.command.1.tlog has changed
Binary file make/vs/idav/x64/Debug/idav.tlog/CL.read.1.tlog has changed
Binary file make/vs/idav/x64/Debug/idav.tlog/CL.write.1.tlog has changed
--- a/make/vs/idav/x64/Debug/idav.tlog/Cl.items.tlog	Sun Nov 10 15:30:46 2024 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-C:\Users\Olaf\Projekte\idav\make\vs\idav\main.c;C:\Users\Olaf\Projekte\idav\make\vs\idav\x64\Debug\main.obj
Binary file make/vs/idav/x64/Debug/idav.tlog/CopyLocal.read.1u.tlog has changed
Binary file make/vs/idav/x64/Debug/idav.tlog/CopyLocal.write.1u.tlog has changed
--- a/make/vs/idav/x64/Debug/idav.tlog/idav.lastbuildstate	Sun Nov 10 15:30:46 2024 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-PlatformToolSet=v143:VCToolArchitecture=Native64Bit:VCToolsVersion=14.37.32822:TargetPlatformVersion=10.0.22621.0:VcpkgTriplet=x64-windows:
-Debug|x64|C:\Users\Olaf\Projekte\idav\make\vs\|
Binary file make/vs/idav/x64/Debug/idav.tlog/link.command.1.tlog has changed
Binary file make/vs/idav/x64/Debug/idav.tlog/link.read.1.tlog has changed
Binary file make/vs/idav/x64/Debug/idav.tlog/link.write.1.tlog has changed
Binary file make/vs/idav/x64/Debug/idav.vcxproj.AssemblyReference.cache has changed
--- a/make/vs/idav/x64/Debug/idav.vcxproj.FileListAbsolute.txt	Sun Nov 10 15:30:46 2024 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-C:\Users\Olaf\Projekte\idav\make\vs\idav\x64\Debug\idav.vcxproj.AssemblyReference.cache
-C:\Users\Olaf\Projekte\idav\make\vs\idav\x64\Debug\idav.vcxproj.CopyComplete
Binary file make/vs/idav/x64/Debug/main.obj has changed
Binary file make/vs/idav/x64/Debug/vc143.idb has changed
Binary file make/vs/idav/x64/Debug/vc143.pdb has changed
--- a/make/vs/idav/x64/Debug/vcpkg.applocal.log	Sun Nov 10 15:30:46 2024 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-
--- a/make/vs/libidav/libidav.vcxproj	Sun Nov 10 15:30:46 2024 +0100
+++ b/make/vs/libidav/libidav.vcxproj	Mon Nov 11 20:45:34 2024 +0100
@@ -149,6 +149,7 @@
     <ClCompile Include="..\..\..\libidav\davqlexec.c" />
     <ClCompile Include="..\..\..\libidav\davqlparser.c" />
     <ClCompile Include="..\..\..\libidav\methods.c" />
+    <ClCompile Include="..\..\..\libidav\pwdstore.c" />
     <ClCompile Include="..\..\..\libidav\resource.c" />
     <ClCompile Include="..\..\..\libidav\session.c" />
     <ClCompile Include="..\..\..\libidav\utils.c" />
@@ -162,6 +163,7 @@
     <ClInclude Include="..\..\..\libidav\davqlexec.h" />
     <ClInclude Include="..\..\..\libidav\davqlparser.h" />
     <ClInclude Include="..\..\..\libidav\methods.h" />
+    <ClInclude Include="..\..\..\libidav\pwdstore.h" />
     <ClInclude Include="..\..\..\libidav\resource.h" />
     <ClInclude Include="..\..\..\libidav\session.h" />
     <ClInclude Include="..\..\..\libidav\utils.h" />
--- a/make/vs/libidav/libidav.vcxproj.filters	Sun Nov 10 15:30:46 2024 +0100
+++ b/make/vs/libidav/libidav.vcxproj.filters	Mon Nov 11 20:45:34 2024 +0100
@@ -48,6 +48,9 @@
     <ClCompile Include="..\..\..\libidav\config.c">
       <Filter>Quelldateien</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\..\libidav\pwdstore.c">
+      <Filter>Quelldateien</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\..\libidav\crypto.h">
@@ -83,5 +86,8 @@
     <ClInclude Include="..\..\..\libidav\config.h">
       <Filter>Quelldateien</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\..\libidav\pwdstore.h">
+      <Filter>Headerdateien</Filter>
+    </ClInclude>
   </ItemGroup>
 </Project>
\ No newline at end of file
--- a/ucx/cx/map.h	Sun Nov 10 15:30:46 2024 +0100
+++ b/ucx/cx/map.h	Mon Nov 11 20:45:34 2024 +0100
@@ -633,113 +633,7 @@
     (void) map->cl->remove(map, cx_hash_key_str(key), false);
 }
 
-/**
- * Removes a key/value-pair from the map by using the key.
- *
- * This function can be used when the map is storing pointers,
- * in order to retrieve the pointer from the map without invoking
- * any destructor function. Sometimes you do not want the pointer
- * to be returned - in that case (instead of suppressing the "unused
- * result" warning) you can use cxMapDetach().
- *
- * If this map is not storing pointers, this function behaves like
- * cxMapRemove() and returns \c NULL.
- *
- * @param map the map
- * @param key the key
- * @return the stored pointer or \c NULL if either the key is not present
- * in the map or the map is not storing pointers
- * @see cxMapStorePointers()
- * @see cxMapDetach()
- */
-__attribute__((__nonnull__, __warn_unused_result__))
-static inline void *cxMapRemoveAndGet(
-        CxMap *map,
-        CxHashKey key
-) {
-    return map->cl->remove(map, key, !map->store_pointer);
-}
 
-/**
- * Removes a key/value-pair from the map by using the key.
- *
- * This function can be used when the map is storing pointers,
- * in order to retrieve the pointer from the map without invoking
- * any destructor function. Sometimes you do not want the pointer
- * to be returned - in that case (instead of suppressing the "unused
- * result" warning) you can use cxMapDetach().
- *
- * If this map is not storing pointers, this function behaves like
- * cxMapRemove() and returns \c NULL.
- *
- * @param map the map
- * @param key the key
- * @return the stored pointer or \c NULL if either the key is not present
- * in the map or the map is not storing pointers
- * @see cxMapStorePointers()
- * @see cxMapDetach()
- */
-__attribute__((__nonnull__, __warn_unused_result__))
-static inline void *cxMapRemoveAndGet(
-        CxMap *map,
-        cxstring key
-) {
-    return map->cl->remove(map, cx_hash_key_cxstr(key), !map->store_pointer);
-}
-
-/**
- * Removes a key/value-pair from the map by using the key.
- *
- * This function can be used when the map is storing pointers,
- * in order to retrieve the pointer from the map without invoking
- * any destructor function. Sometimes you do not want the pointer
- * to be returned - in that case (instead of suppressing the "unused
- * result" warning) you can use cxMapDetach().
- *
- * If this map is not storing pointers, this function behaves like
- * cxMapRemove() and returns \c NULL.
- *
- * @param map the map
- * @param key the key
- * @return the stored pointer or \c NULL if either the key is not present
- * in the map or the map is not storing pointers
- * @see cxMapStorePointers()
- * @see cxMapDetach()
- */
-__attribute__((__nonnull__, __warn_unused_result__))
-static inline void *cxMapRemoveAndGet(
-        CxMap *map,
-        cxmutstr key
-) {
-    return map->cl->remove(map, cx_hash_key_cxstr(key), !map->store_pointer);
-}
-
-/**
- * Removes a key/value-pair from the map by using the key.
- *
- * This function can be used when the map is storing pointers,
- * in order to retrieve the pointer from the map without invoking
- * any destructor function. Sometimes you do not want the pointer
- * to be returned - in that case (instead of suppressing the "unused
- * result" warning) you can use cxMapDetach().
- *
- * If this map is not storing pointers, this function behaves like
- * cxMapRemove() and returns \c NULL.
- *
- * @param map the map
- * @param key the key
- * @return the stored pointer or \c NULL if either the key is not present
- * in the map or the map is not storing pointers
- * @see cxMapStorePointers()
- * @see cxMapDetach()
- */
-__attribute__((__nonnull__, __warn_unused_result__))
-static inline void *cxMapRemoveAndGet(
-        CxMap *map,
-        const char *key
-) {
-    return map->cl->remove(map, cx_hash_key_str(key), !map->store_pointer);
-}
 
 #else // __cplusplus
 
--- a/ui/common/context.c	Sun Nov 10 15:30:46 2024 +0100
+++ b/ui/common/context.c	Mon Nov 11 20:45:34 2024 +0100
@@ -41,6 +41,7 @@
 #include "document.h"
 #include "types.h"
 
+
 static UiContext* global_context;
 
 void uic_init_global_context(void) {
--- a/ui/common/document.c	Sun Nov 10 15:30:46 2024 +0100
+++ b/ui/common/document.c	Mon Nov 11 20:45:34 2024 +0100
@@ -35,6 +35,7 @@
 #include <cx/hash_map.h>
 #include <cx/mempool.h>
 
+
 static CxMap *documents;
 
 void uic_docmgr_init() {
--- a/ui/common/menu.c	Sun Nov 10 15:30:46 2024 +0100
+++ b/ui/common/menu.c	Mon Nov 11 20:45:34 2024 +0100
@@ -34,6 +34,7 @@
 #include <cx/linked_list.h>
 #include <cx/array_list.h>
 
+
 static UiMenu *menus_begin;
 static UiMenu *menus_end;
 static CxList *current;
--- a/ui/common/properties.c	Sun Nov 10 15:30:46 2024 +0100
+++ b/ui/common/properties.c	Mon Nov 11 20:45:34 2024 +0100
@@ -60,6 +60,14 @@
     return ui_configfile(NULL);
 }
 
+#ifndef _WIN32
+#define UI_PATH_SEPARATOR '/'
+#define UI_ENV_HOME "HOME"
+#else
+#define UI_PATH_SEPARATOR '\\'
+#define UI_ENV_HOME "USERPROFILE"
+#endif
+
 char* ui_configfile(char *name) {
     const char *appname = ui_appname();
     if(!appname) {
@@ -70,7 +78,7 @@
     cxBufferInit(&buf, NULL, 128, cxDefaultAllocator, CX_BUFFER_FREE_CONTENTS|CX_BUFFER_AUTO_EXTEND);
     
     // add base dir
-    char *homeenv = getenv("HOME");
+    char *homeenv = getenv(UI_ENV_HOME);
     if(homeenv == NULL) {
         cxBufferDestroy(&buf);
         return NULL;
@@ -78,19 +86,22 @@
     cxstring home = cx_str(homeenv);
     
     cxBufferWrite(home.ptr, 1, home.length, &buf);
-    if(home.ptr[home.length-1] != '/') {
-        cxBufferPut(&buf, '/');
+    if(home.ptr[home.length-1] != UI_PATH_SEPARATOR) {
+        cxBufferPut(&buf, UI_PATH_SEPARATOR);
     }
     
 #ifdef UI_COCOA
     // on OS X the app dir is $HOME/Library/Application Support/$APPNAME/
-    ucx_buffer_puts(buf, "Library/Application Support/");
+    cxBufferPutString(&buf, "Library/Application Support/");
+#elif defined(_WIN32)
+    // on Windows the app dir is $USERPROFILE/AppData/Local/$APPNAME/
+    cxBufferPutString(&buf, "AppData\\Local\\");
 #else
     // app dir is $HOME/.$APPNAME/
     cxBufferPut(&buf, '.');
 #endif
     cxBufferPutString(&buf, appname);
-    cxBufferPut(&buf, '/');
+    cxBufferPut(&buf, UI_PATH_SEPARATOR);
     
     // add file name
     if(name) {
--- a/ui/ui/properties.h	Sun Nov 10 15:30:46 2024 +0100
+++ b/ui/ui/properties.h	Mon Nov 11 20:45:34 2024 +0100
@@ -30,12 +30,13 @@
 #define	UI_PROPERTIES_H
 
 #include "toolkit.h"
+#include <cx/map.h>
 
 #ifdef	__cplusplus
 extern "C" {
 #endif
 
-typedef struct CxMap UiProperties;
+typedef CxMap UiProperties;
 
 char* ui_get_property(char *name);
 void  ui_set_property(char *name, char *value);
--- a/ui/winui/text.cpp	Sun Nov 10 15:30:46 2024 +0100
+++ b/ui/winui/text.cpp	Mon Nov 11 20:45:34 2024 +0100
@@ -56,7 +56,9 @@
     UiObject* current = uic_current_obj(obj);
 
     // create textarea and toolkit wrapper
-    RichEditBox textarea = RichEditBox();
+    TextBox textarea = TextBox();
+    textarea.AcceptsReturn(true);
+    ScrollViewer::SetVerticalScrollBarVisibility(textarea, ScrollBarVisibility::Auto);
     UIElement elm = textarea;
     UiWidget* widget = new UiWidget(elm);
     ui_context_add_widget_destructor(current->ctx, widget);
@@ -97,14 +99,46 @@
 
 }
 
+// -------------------------- getter/setter for textarea UiText --------------------------
 
+char* ui_wtext_get(UiText *text, std::wstring &value) {
+    if (text->value.ptr) {
+        text->value.free(text->value.ptr);
+    }
+
+    text->value.ptr = wchar2utf8(value.c_str(), value.length());
+    text->value.free = free;
+
+    return text->value.ptr;
+}
+
+std::wstring ui_wtext_set(UiText *text, const char* value) {
+    if (text->value.ptr) {
+        text->value.free(text->value.ptr);
+    }
+
+    text->value.ptr = _strdup(value);
+    text->value.free = free;
+
+    int len;
+    wchar_t* wstr = str2wstr(value, &len);
+    std::wstring s(wstr);
+    free(wstr);
+
+    return s;
+}
 
 extern "C" char* ui_textarea_get(UiText *text) {
-    return NULL;
+    UiWidget* widget = (UiWidget*)text->obj;
+    TextBox box = widget->uielement.as<TextBox>();
+    std::wstring wstr(box.Text());
+    return ui_wtext_get(text, wstr);
 }
 
 extern "C" void  ui_textarea_set(UiText *text, const char *newvalue) {
-
+    UiWidget* widget = (UiWidget*)text->obj;
+    TextBox box = widget->uielement.as<TextBox>();
+    box.Text(ui_wtext_set(text, newvalue));
 }
 
 extern "C" char* ui_textarea_getsubstr(UiText *text, int begin, int end) {
--- a/ui/winui/text.h	Sun Nov 10 15:30:46 2024 +0100
+++ b/ui/winui/text.h	Mon Nov 11 20:45:34 2024 +0100
@@ -60,6 +60,9 @@
     void* ondropdata;
 };
 
+char* ui_wtext_get(UiText *text, std::wstring &value);
+std::wstring ui_wtext_set(UiText *text, const char* value);
+
 char* ui_wstring_get(UiString* str, std::wstring& value);
 std::wstring ui_wstring_set(UiString* str, const char* value);
 
--- a/ui/winui/toolkit.cpp	Sun Nov 10 15:30:46 2024 +0100
+++ b/ui/winui/toolkit.cpp	Mon Nov 11 20:45:34 2024 +0100
@@ -36,6 +36,7 @@
 #include "../common/context.h"
 #include "../common/document.h"
 #include "../common/toolbar.h"
+#include "../common/properties.h"
 
 #include "icons.h"
 
@@ -166,6 +167,8 @@
 	uic_init_global_context();
 	uic_docmgr_init();
 	uic_toolbar_init();
+	
+	uic_load_app_properties();
 }
 
 const char* ui_appname() {
--- a/ui/winui/winui.vcxproj	Sun Nov 10 15:30:46 2024 +0100
+++ b/ui/winui/winui.vcxproj	Mon Nov 11 20:45:34 2024 +0100
@@ -88,8 +88,9 @@
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
     <ClCompile>
-      <PreprocessorDefinitions>_DEBUG;DISABLE_XAML_GENERATED_MAIN__;UI_WINUI;UI_WINUI_PCH;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>_DEBUG;DISABLE_XAML_GENERATED_MAIN__;UI_WINUI;UI_WINUI_PCH;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)..\..\ucx;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <LanguageStandard_C Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">stdc17</LanguageStandard_C>
     </ClCompile>
     <Link>
       <AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">shell32.lib;gdi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
@@ -113,6 +114,14 @@
     <Manifest Include="app.manifest" />
   </ItemGroup>
   <ItemGroup>
+    <ClInclude Include="..\common\context.h" />
+    <ClInclude Include="..\common\document.h" />
+    <ClInclude Include="..\common\menu.h" />
+    <ClInclude Include="..\common\object.h" />
+    <ClInclude Include="..\common\properties.h" />
+    <ClInclude Include="..\common\toolbar.h" />
+    <ClInclude Include="..\common\types.h" />
+    <ClInclude Include="..\common\ucx_properties.h" />
     <ClInclude Include="..\ui\button.h" />
     <ClInclude Include="..\ui\container.h" />
     <ClInclude Include="..\ui\display.h" />
@@ -160,6 +169,30 @@
     <Page Include="MainWindow.xaml" />
   </ItemGroup>
   <ItemGroup>
+    <ClCompile Include="..\common\context.c">
+      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
+    </ClCompile>
+    <ClCompile Include="..\common\document.c">
+      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
+    </ClCompile>
+    <ClCompile Include="..\common\menu.c">
+      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
+    </ClCompile>
+    <ClCompile Include="..\common\object.c">
+      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
+    </ClCompile>
+    <ClCompile Include="..\common\properties.c">
+      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
+    </ClCompile>
+    <ClCompile Include="..\common\toolbar.c">
+      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
+    </ClCompile>
+    <ClCompile Include="..\common\types.c">
+      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
+    </ClCompile>
+    <ClCompile Include="..\common\ucx_properties.c">
+      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
+    </ClCompile>
     <ClCompile Include="appmenu.cpp" />
     <ClCompile Include="button.cpp" />
     <ClCompile Include="commandbar.cpp" />
@@ -226,9 +259,6 @@
     <ProjectReference Include="..\..\make\vs\ucx\ucx.vcxproj">
       <Project>{27da0164-3475-43e2-a1a4-a5d07d305749}</Project>
     </ProjectReference>
-    <ProjectReference Include="..\..\make\vs\uicommon\uicommon.vcxproj">
-      <Project>{8b88698e-c185-4383-99fe-0c34d6deed2e}</Project>
-    </ProjectReference>
   </ItemGroup>
   <!--
     Defining the "HasPackageAndPublishMenuAddedByProject" property here allows the Solution
--- a/ui/winui/winui.vcxproj.filters	Sun Nov 10 15:30:46 2024 +0100
+++ b/ui/winui/winui.vcxproj.filters	Mon Nov 11 20:45:34 2024 +0100
@@ -29,6 +29,30 @@
     <ClCompile Include="dnd.cpp" />
     <ClCompile Include="condvar.cpp" />
     <ClCompile Include="image.cpp" />
+    <ClCompile Include="..\common\context.c">
+      <Filter>common</Filter>
+    </ClCompile>
+    <ClCompile Include="..\common\document.c">
+      <Filter>common</Filter>
+    </ClCompile>
+    <ClCompile Include="..\common\menu.c">
+      <Filter>common</Filter>
+    </ClCompile>
+    <ClCompile Include="..\common\object.c">
+      <Filter>common</Filter>
+    </ClCompile>
+    <ClCompile Include="..\common\properties.c">
+      <Filter>common</Filter>
+    </ClCompile>
+    <ClCompile Include="..\common\toolbar.c">
+      <Filter>common</Filter>
+    </ClCompile>
+    <ClCompile Include="..\common\types.c">
+      <Filter>common</Filter>
+    </ClCompile>
+    <ClCompile Include="..\common\ucx_properties.c">
+      <Filter>common</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="pch.h" />
@@ -102,6 +126,30 @@
     <ClInclude Include="..\ui\icons.h">
       <Filter>public</Filter>
     </ClInclude>
+    <ClInclude Include="..\common\context.h">
+      <Filter>common</Filter>
+    </ClInclude>
+    <ClInclude Include="..\common\document.h">
+      <Filter>common</Filter>
+    </ClInclude>
+    <ClInclude Include="..\common\menu.h">
+      <Filter>common</Filter>
+    </ClInclude>
+    <ClInclude Include="..\common\object.h">
+      <Filter>common</Filter>
+    </ClInclude>
+    <ClInclude Include="..\common\properties.h">
+      <Filter>common</Filter>
+    </ClInclude>
+    <ClInclude Include="..\common\toolbar.h">
+      <Filter>common</Filter>
+    </ClInclude>
+    <ClInclude Include="..\common\types.h">
+      <Filter>common</Filter>
+    </ClInclude>
+    <ClInclude Include="..\common\ucx_properties.h">
+      <Filter>common</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <Image Include="Assets\Wide310x150Logo.scale-200.png">
@@ -133,6 +181,9 @@
     <Filter Include="public">
       <UniqueIdentifier>{2b58fe46-d27b-4335-b63c-13ec2204fa24}</UniqueIdentifier>
     </Filter>
+    <Filter Include="common">
+      <UniqueIdentifier>{35c88d5c-b36f-41b3-86c0-784227845ae9}</UniqueIdentifier>
+    </Filter>
   </ItemGroup>
   <ItemGroup>
     <Text Include="readme.txt" />

mercurial