package de.unixwork.rssreader
import de.unixwork.ui.Document
+import de.unixwork.ui.Toolkit
import de.unixwork.ui.UiLinkData
import de.unixwork.ui.kotlin.ToolkitDispatcher
import kotlinx.coroutines.Dispatchers
items.update(items.selectedIndex)
}
}
+
+ fun openCurrentUri() {
+ currentItem?.let { item ->
+ item.link?.let {
+ Toolkit.openUri(it)
+ }
+ }
+ }
}
\ No newline at end of file
throw new RuntimeException(e);
}
}
+
+ public static void openUri(String uri) {
+ ToolkitFuncs ui = ToolkitFuncs.getInstance();
+ try(Arena arena = Arena.ofConfined()) {
+ MemorySegment uriCstr = arena.allocateFrom(uri);
+ ui.open_uri.invoke(uriCstr);
+ } catch (Throwable e) {
+ throw new RuntimeException(e);
+ }
+ }
}
public MethodHandle getappdir;
public MethodHandle configfile;
+ public MethodHandle open_uri;
+
// some libc stuff
public MethodHandle malloc;
public MethodHandle free;
MemorySegment getappdir_addr = lib.find("ui_getappdir").orElseThrow();
MemorySegment configfile_addr = lib.find("ui_configfile").orElseThrow();
+ MemorySegment open_uri_addr = lib.find("ui_open_uri").orElseThrow();
+
MemorySegment malloc_addr = lib.find("malloc").orElseThrow();
MemorySegment free_addr = lib.find("free").orElseThrow();
MemorySegment strlen_addr = lib.find("strlen").orElseThrow();
getappdir = linker.downcallHandle(getappdir_addr, sigm);
configfile = linker.downcallHandle(configfile_addr, sigm_m);
+ open_uri = linker.downcallHandle(open_uri_addr, sigv_m);
+
ui_malloc = linker.downcallHandle(ui_malloc_addr, sigm_ml);
ui_free = linker.downcallHandle(ui_free_addr, sigv_mm);