aboutsummaryrefslogtreecommitdiff
path: root/c/datalistview.c
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2022-02-15 16:29:59 +0100
committerJohn Ankarström <john@ankarstrom.se>2022-02-15 16:29:59 +0100
commit52fb337856497cb151081f3738e7cfa4bc2883bd (patch)
tree3309edbd0834bf90a5635b93038d1d088224e96e /c/datalistview.c
parent09ec144a99f1234a37d04854bdfb81485540be97 (diff)
downloadEpisodeBrowser-52fb337856497cb151081f3738e7cfa4bc2883bd.tar.gz
Rework list view code.
Diffstat (limited to 'c/datalistview.c')
-rw-r--r--c/datalistview.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/c/datalistview.c b/c/datalistview.c
new file mode 100644
index 0000000..4980d3b
--- /dev/null
+++ b/c/datalistview.c
@@ -0,0 +1,60 @@
+#include <windows.h>
+#include <SWI-Prolog.h>
+
+#include "resource.h"
+#include "datalistview.h"
+
+HWND gDlv_hWnd;
+
+void
+DlvCreate(HWND hWnd)
+{
+ gDlv_hWnd = hWnd;
+}
+
+/* Show episode data. */
+void
+DlvShowEpisode(int iEpisode)
+{
+ int r;
+ term_t t;
+
+ t = PL_new_term_refs(3);
+ if(!PL_put_integer(t+0, iEpisode))
+ return;
+
+ r = PL_call_predicate(NULL, PL_Q_NORMAL,
+ PL_predicate("lookup_episode_local", 3, "episode_data"),
+ t);
+ if (!r)
+ return;
+
+ /* The episode data is a list of unary compounds,
+ * whose functor is the key and whose argument is the value. */
+
+ {
+ term_t tHead, tList;
+
+ tHead = PL_new_term_ref();
+ tList = PL_copy_term_ref(t+2);
+
+ while (PL_get_list(tList, tHead, tList)) {
+ atom_t aKey;
+ const char *szKey;
+ char *szValue;
+ term_t tValue;
+ size_t iArity;
+
+ if (!PL_get_name_arity(tHead, &aKey, &iArity))
+ continue;
+ szKey = PL_atom_chars(aKey);
+
+ if (!PL_get_arg(1, tHead, tValue))
+ continue;
+ if (!PL_get_atom_chars(tValue, &szValue))
+ continue;
+
+ //printf("%s/%d: %s\n", szKey, iArity, szValue);
+ }
+ }
+}