c89-ification

git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@387 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
NishiOwO
2025-10-17 00:16:02 +00:00
parent f4eed938cf
commit 758ae46138
8 changed files with 80 additions and 30 deletions

View File

@@ -103,3 +103,16 @@ void MwDirectoryFreeEntry(MwDirectoryEntry* entry) {
free(entry->name);
free(entry);
}
char* MwDirectoryCurrent(void) {
#ifdef _WIN32
int len = GetCurrentDirectory(0, NULL);
char* out = malloc(len);
GetCurrentDirectory(len, out);
return out;
#else
return getcwd(NULL, 0);
#endif
}

View File

@@ -237,6 +237,10 @@ static void resize(MwWidget handle, void* user, void* call) {
static void scan(MwWidget handle, const char* path) {
filechooser_t* fc = handle->opaque;
MwVaApply(fc->addr,
MwNtext, path,
NULL);
MwListBoxReset(fc->files);
MwListBoxInsert(fc->files, -1, NULL, "Name", "Date modified", "Size", NULL);
MwListBoxSetWidth(fc->files, 0, -128 - 64);
@@ -251,6 +255,7 @@ MwWidget MwFileChooser(MwWidget handle, const char* title) {
int wh = MwGetInteger(handle, MwNheight);
int w, h;
filechooser_t* fc = malloc(sizeof(*fc));
char* path;
memset(fc, 0, sizeof(*fc));
@@ -275,7 +280,9 @@ MwWidget MwFileChooser(MwWidget handle, const char* title) {
layout(window);
MwAddUserHandler(window, MwNresizeHandler, resize, NULL);
scan(window, ".");
path = MwDirectoryCurrent();
scan(window, path);
free(path);
MwLLDetach(window->lowlevel, &p);
MwLLMakePopup(window->lowlevel, handle->lowlevel);

View File

@@ -117,13 +117,17 @@ static void key(MwWidget handle, int code) {
MwForceRender(handle);
}
static void prop_change(MwWidget handle, const char* prop) {
if(strcmp(prop, MwNtext) == 0) MwForceRender(handle);
}
MwClassRec MwEntryClassRec = {
create, /* create */
destroy, /* destroy */
draw, /* draw */
NULL, /* click */
NULL, /* parent_resize */
NULL, /* prop_change */
prop_change, /* prop_change */
NULL, /* mouse_move */
MwForceRender2, /* mouse_up */
MwForceRender2, /* mouse_down */

View File

@@ -126,17 +126,21 @@ static void mouse_down(MwWidget handle, void* ptr) {
MwForceRender(handle);
}
static void prop_change(MwWidget handle, const char* prop) {
if(strcmp(prop, MwNtext) == 0) MwForceRender(handle);
}
MwClassRec MwNumberEntryClassRec = {
create, /* create */
destroy, /* destroy */
draw, /* draw */
NULL, /* click */
NULL, /* parent_resize */
NULL, /* prop_change */
mouse_move, /* mouse_move */
mouse_up, /* mouse_up */
mouse_down, /* mouse_down */
key, /* key */
create, /* create */
destroy, /* destroy */
draw, /* draw */
NULL, /* click */
NULL, /* parent_resize */
prop_change, /* prop_change */
mouse_move, /* mouse_move */
mouse_up, /* mouse_up */
mouse_down, /* mouse_down */
key, /* key */
NULL,
NULL,
NULL,

View File

@@ -132,7 +132,7 @@ static void draw(MwWidget handle) {
}
static void mouse_move(MwWidget handle) {
int or = MwGetInteger(handle, MwNorientation);
int or = MwGetInteger(handle, MwNorientation);
scrollbar_t* scr = handle->internal;
if(!handle->pressed) return;
@@ -160,9 +160,9 @@ static void mouse_move(MwWidget handle) {
}
static void mouse_down(MwWidget handle, void* ptr) {
int ww = MwGetInteger(handle, MwNwidth);
int wh = MwGetInteger(handle, MwNheight);
int or = MwGetInteger(handle, MwNorientation);
int ww = MwGetInteger(handle, MwNwidth);
int wh = MwGetInteger(handle, MwNheight);
int or = MwGetInteger(handle, MwNorientation);
scrollbar_t* scr = handle->internal;
MwLLMouse* m = ptr;