aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHanspeter Portner <dev@open-music-kontrollers.ch>2016-04-05 20:34:52 +0200
committerHanspeter Portner <dev@open-music-kontrollers.ch>2016-04-05 20:34:52 +0200
commit6ba17a545f3a4df763aa75a31dd42275925e6cef (patch)
treee9fad7e304c408b498391779ca369197957cd466
parentbfbbc743fb933409a3ead2af8c744b30c694dc86 (diff)
downloadsherlock.lv2-6ba17a545f3a4df763aa75a31dd42275925e6cef.tar.xz (sig)
redesign sherlock#atom_inspector.0.1.2
* show turtle instead of atom object genlist * fix detection of maximal amount of events
-rw-r--r--CMakeLists.txt10
-rw-r--r--atom_inspector_eo.c892
-rw-r--r--common.h36
-rw-r--r--encoder.l254
-rw-r--r--midi_inspector_eo.c56
-rw-r--r--osc_inspector_eo.c60
-rw-r--r--sherlock.h1
-rw-r--r--sherlock.ttl12
8 files changed, 533 insertions, 788 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5ede036..0e7abc6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -59,13 +59,19 @@ target_link_libraries(sherlock_ui
set_target_properties(sherlock_ui PROPERTIES PREFIX "")
install(TARGETS sherlock_ui DESTINATION ${DEST})
+find_package(FLEX)
+flex_target(encoder encoder.l ${PROJECT_BINARY_DIR}/encoder.c
+ COMPILE_FLAGS "--header-file=${PROJECT_BINARY_DIR}/encoder.h --prefix=enc")
+
add_library(sherlock_eo MODULE
sherlock_eo.c
atom_inspector_eo.c
midi_inspector_eo.c
- osc_inspector_eo.c)
+ osc_inspector_eo.c
+ ${FLEX_encoder_OUTPUTS})
target_link_libraries(sherlock_eo
- ${ELM_LDFLAGS})
+ ${ELM_LDFLAGS}
+ ${SRATOM_LDFLAGS})
set_target_properties(sherlock_eo PROPERTIES PREFIX "")
install(TARGETS sherlock_eo DESTINATION ${DEST})
diff --git a/atom_inspector_eo.c b/atom_inspector_eo.c
index a19de3c..6a5109f 100644
--- a/atom_inspector_eo.c
+++ b/atom_inspector_eo.c
@@ -16,24 +16,25 @@
*/
#include <inttypes.h>
+#include <stdio.h>
#include <sherlock.h>
+#include <common.h>
#include <Elementary.h>
+#include <sratom/sratom.h>
+
#define COUNT_MAX 2048 // maximal amount of events shown
#define STRING_BUF_SIZE 2048
#define STRING_MAX 256
#define STRING_OFF (STRING_MAX - 4)
-// Disable deprecation warnings for Blank and Resource
-#if defined(__clang__)
-# pragma clang diagnostic push
-# pragma clang diagnostic ignored "-Wdeprecated-declarations"
-#elif __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
-# pragma GCC diagnostic push
-# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-#endif
+#define NS_RDF (const uint8_t*)"http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+#define NS_XSD (const uint8_t*)"http://www.w3.org/2001/XMLSchema#"
+#define NS_OSC (const uint8_t*)"http://open-music-kontrollers.ch/lv2/osc#"
+#define NS_XPRESS (const uint8_t*)"http://open-music-kontrollers.ch/lv2/xpress#"
+#define NS_SPOD (const uint8_t*)"http://open-music-kontrollers.ch/lv2/synthpod#"
typedef struct _UI UI;
@@ -44,20 +45,7 @@ struct _UI {
LV2_URID_Map *map;
LV2_URID_Unmap *unmap;
struct {
- LV2_URID midi_MidiEvent;
-
LV2_URID event_transfer;
-
- LV2_URID time_position;
- LV2_URID time_barBeat;
- LV2_URID time_bar;
- LV2_URID time_beat;
- LV2_URID time_beatUnit;
- LV2_URID time_beatsPerBar;
- LV2_URID time_beatsPerMinute;
- LV2_URID time_frame;
- LV2_URID time_framesPerSecond;
- LV2_URID time_speed;
} uris;
LV2_Atom_Forge forge;
@@ -71,37 +59,65 @@ struct _UI {
Evas_Object *autoblock;
Evas_Object *popup;
- Elm_Genlist_Item_Class *itc_sherlock;
Elm_Genlist_Item_Class *itc_list;
Elm_Genlist_Item_Class *itc_group;
- Elm_Genlist_Item_Class *itc_seq;
- Elm_Genlist_Item_Class *itc_prop;
- Elm_Genlist_Item_Class *itc_vec;
- Elm_Genlist_Item_Class *itc_atom;
char string_buf [STRING_BUF_SIZE];
char *logo_path;
Eina_Hash *urids;
+
+ Sratom *sratom;
+ const char *base_uri;
+
+ char *chunk;
};
-static inline int
-_is_expandable(UI *ui, const uint32_t type)
+#define CODE_PRE "<style=shadow,bottom>"
+#define CODE_POST "</style>"
+
+#define URI(VAL,TYP) ("<color=#bbb font=Mono><b>"VAL"</b></color> <color=#fff font=Default>"TYP"</color>")
+
+static void
+_encoder_begin(void *data)
{
- return lv2_atom_forge_is_object_type(&ui->forge, type)
- || (type == ui->forge.Tuple)
- || (type == ui->forge.Vector)
- || (type == ui->forge.Sequence);
+ UI *ui = data;
+
+ ui->chunk = strdup("");
}
-#define CODE_PRE "<style=shadow,bottom>"
-#define CODE_POST "</style>"
+static void
+_encoder_append(const char *str, void *data)
+{
+ UI *ui = data;
-#define HIL_PRE(VAL) ("<color=#bbb font=Mono><b>"VAL"</b></color> <color=#b00 font=Mono>")
-#define HIL_POST ("</color>")
+ size_t size = 0;
+ size += ui->chunk ? strlen(ui->chunk) : 0;
+ size += str ? strlen(str) + 1 : 0;
-#define URI(VAL,TYP) ("<color=#bbb font=Mono><b>"VAL"</b></color> <color=#fff font=Default>"TYP"</color>")
-#define HIL(VAL,TYP) ("<color=#bbb font=Mono><b>"VAL"</b></color> <color=#b00 font=Mono>"TYP"</color>")
+ if(size)
+ ui->chunk = realloc(ui->chunk, size);
+
+ if(ui->chunk && str)
+ strcat(ui->chunk, str);
+}
+
+static void
+_encoder_end(void *data)
+{
+ UI *ui = data;
+
+ elm_entry_entry_set(ui->info, ui->chunk);
+ free(ui->chunk);
+}
+
+static moony_encoder_t enc = {
+ .begin = _encoder_begin,
+ .append = _encoder_append,
+ .end = _encoder_end,
+ .data = NULL
+};
+moony_encoder_t *encoder = &enc;
static void
_hash_del(void *data)
@@ -135,359 +151,6 @@ _hash_get(UI *ui, LV2_URID urid)
return uri;
}
-static char *
-_atom_stringify(UI *ui, char *ptr, char *end, int newline, const LV2_Atom *atom)
-{
- //FIXME check for buffer overflows!!!
- sprintf(ptr, CODE_PRE);
- ptr += strlen(ptr);
-
- const char *type = _hash_get(ui, atom->type);
- sprintf(ptr, URI("type ", "%s (%"PRIu32")"), type, atom->type);
- ptr += strlen(ptr);
-
- if(lv2_atom_forge_is_object_type(&ui->forge, atom->type))
- {
- const LV2_Atom_Object *atom_object = (const LV2_Atom_Object *)atom;
- const char *id = atom_object->body.id
- ? _hash_get(ui, atom_object->body.id)
- : NULL;
- const char *otype = _hash_get(ui, atom_object->body.otype);
-
- if(id)
- {
- sprintf(ptr, URI("</br>id ", "%s (%"PRIu32")"), id, atom_object->body.id);
- ptr += strlen(ptr);
-
- if(newline)
- sprintf(ptr, "</br>");
- else
- sprintf(ptr, "</tab>");
- }
- else // !id
- {
- sprintf(ptr, "</br>");
- ptr += strlen(ptr);
-
- if(newline)
- sprintf(ptr, "</br>");
- }
- ptr += strlen(ptr);
-
- sprintf(ptr, URI("otype ", "%s (%"PRIu32")"), otype, atom_object->body.otype);
- }
- else if(atom->type == ui->forge.Tuple)
- {
- const LV2_Atom_Tuple *atom_tuple = (const LV2_Atom_Tuple *)atom;
-
- // do nothing
- sprintf(ptr, "</br>");
- }
- else if(atom->type == ui->forge.Vector)
- {
- const LV2_Atom_Vector *atom_vector = (const LV2_Atom_Vector *)atom;
- const char *ctype = _hash_get(ui, atom_vector->body.child_type);
-
- sprintf(ptr, URI("</br>ctype ", "%s (%"PRIu32")"), ctype, atom_vector->body.child_type);
- ptr += strlen(ptr);
-
- if(newline)
- sprintf(ptr, "</br>");
- else
- sprintf(ptr, "</tab>");
- ptr += strlen(ptr);
-
- sprintf(ptr, URI("csize ", "%"PRIu32), atom_vector->body.child_size);
- }
- else if(atom->type == ui->forge.Sequence)
- {
- const LV2_Atom_Sequence *atom_seq = (const LV2_Atom_Sequence *)atom;
-
- // do nothing
- sprintf(ptr, "</br>");
- }
- else if(atom->type == ui->forge.Int)
- {
- const LV2_Atom_Int *atom_int = (const LV2_Atom_Int *)atom;
-
- sprintf(ptr, HIL("</br>value ", "%"PRIi32), atom_int->body);
- }
- else if(atom->type == ui->forge.Long)
- {
- const LV2_Atom_Long *atom_long = (const LV2_Atom_Long *)atom;
-
- sprintf(ptr, HIL("</br>value ", "%"PRIi64), atom_long->body);
- }
- else if(atom->type == ui->forge.Float)
- {
- const LV2_Atom_Float *atom_float = (const LV2_Atom_Float *)atom;
-
- sprintf(ptr, HIL("</br>value ", "%f"), atom_float->body);
- }
- else if(atom->type == ui->forge.Double)
- {
- const LV2_Atom_Double *atom_double = (const LV2_Atom_Double *)atom;
-
- sprintf(ptr, HIL("</br>value ", "%lf"), atom_double->body);
- }
- else if(atom->type == ui->forge.Bool)
- {
- const LV2_Atom_Int *atom_int = (const LV2_Atom_Int *)atom;
-
- sprintf(ptr, HIL("</br>value ", "%s"), atom_int->body ? "true" : "false");
- }
- else if(atom->type == ui->forge.URID)
- {
- const LV2_Atom_URID *atom_urid = (const LV2_Atom_URID *)atom;
- const char *uri = _hash_get(ui, atom_urid->body);
-
- sprintf(ptr, HIL("</br>value ", "%"PRIu32" (%s)"), atom_urid->body, uri);
- }
- else if(atom->type == ui->forge.String)
- {
- char *str = LV2_ATOM_CONTENTS(LV2_Atom_String, atom);
- if(atom->size == 0)
- str = "";
-
- // truncate
- char tmp[4] = {'\0'};
- if(atom->size > STRING_MAX)
- {
- memcpy(tmp, &str[STRING_OFF], 4);
- strcpy(&str[STRING_OFF], "...");
- }
-
- sprintf(ptr, HIL("</br>value ", "%s"), str);
-
- // restore
- if(atom->size > STRING_MAX)
- memcpy(&str[STRING_OFF], tmp, 4);
- }
- else if(atom->type == ui->forge.Path)
- {
- char *str = LV2_ATOM_CONTENTS(LV2_Atom_String, atom);
- if(atom->size == 0)
- str = "";
-
- // truncate
- char tmp[4] = {'\0'};
- if(atom->size > STRING_MAX)
- {
- memcpy(tmp, &str[STRING_OFF], 4);
- strcpy(&str[STRING_OFF], "...");
- }
-
- sprintf(ptr, HIL("</br>value ", "%s"), str);
-
- // restore
- if(atom->size > STRING_MAX)
- memcpy(&str[STRING_OFF], tmp, 4);
- }
- else if(atom->type == ui->forge.Literal)
- {
- const LV2_Atom_Literal *atom_lit = (const LV2_Atom_Literal *)atom;
-
- char *str = LV2_ATOM_CONTENTS(LV2_Atom_Literal, atom);
- if(atom->size == sizeof(LV2_Atom_Literal_Body))
- str = "";
- const char *datatype = _hash_get(ui, atom_lit->body.datatype);
- const char *lang = _hash_get(ui, atom_lit->body.lang);
-
- // truncate
- char tmp[4] = {'\0'};
- if(atom->size > STRING_MAX)
- {
- memcpy(tmp, &str[STRING_OFF], 4);
- strcpy(&str[STRING_OFF], "...");
- }
-
- sprintf(ptr, HIL("</br>value ", "%s"), str);
- ptr += strlen(ptr);
-
- // restore
- if(atom->size > STRING_MAX)
- memcpy(&str[STRING_OFF], tmp, 4);
-
- if(newline)
- sprintf(ptr, "</br>");
- else
- sprintf(ptr, "</tab>");
- ptr += strlen(ptr);
-
- sprintf(ptr, URI("datatype", "%s (%"PRIu32")"), datatype, atom_lit->body.datatype);
- ptr += strlen(ptr);
-
- sprintf(ptr, URI("</tab>lang ", "%s (%"PRIu32")"), lang, atom_lit->body.lang);
- }
- else if(atom->type == ui->forge.URI)
- {
- char *str = LV2_ATOM_CONTENTS(LV2_Atom_String, atom);
- if(atom->size == 0)
- str = "";
- LV2_URID urid = ui->map->map(ui->map->handle, str); //TODO add hashing
-
- // truncate
- char tmp[4] = {'\0'};
- if(atom->size > STRING_MAX)
- {
- memcpy(tmp, &str[STRING_OFF], 4);
- strcpy(&str[STRING_OFF], "...");
- }
-
- sprintf(ptr, HIL("</br>value ", "%s (%"PRIu32")"), str, urid);
-
- // restore
- if(atom->size > STRING_MAX)
- memcpy(&str[STRING_OFF], tmp, 4);
- }
- else if(atom->type == ui->uris.midi_MidiEvent)
- {
- const uint8_t *midi = LV2_ATOM_BODY_CONST(atom);
-
- sprintf(ptr, HIL_PRE("</br>value "));
- ptr += strlen(ptr);
-
- char *barrier = ptr + STRING_OFF;
- for(unsigned i=0; (i<atom->size) && (ptr<barrier); i++, ptr += 3)
- sprintf(ptr, "%02X ", midi[i]);
-
- if(ptr >= barrier) // there would be more to print
- {
- ptr = barrier;
- sprintf(ptr, "...");
- ptr += 4;
- }
-
- sprintf(ptr, HIL_POST);
- }
- else if(atom->type == ui->forge.Chunk)
- {
- const uint8_t *chunk = LV2_ATOM_BODY_CONST(atom);
-
- sprintf(ptr, HIL_PRE("</br>value "));
- ptr += strlen(ptr);
-
- char *barrier = ptr + STRING_OFF;
- for(unsigned i=0; (i<atom->size) && (ptr<barrier); i++, ptr += 3)
- sprintf(ptr, "%02"PRIX8" ", chunk[i]);
-
- if(ptr >= barrier) // there would be more to print
- {
- ptr = barrier;
- sprintf(ptr, "...");
- ptr += 4;
- }
-
- sprintf(ptr, HIL_POST);
- }
-
- if( newline
- && !lv2_atom_forge_is_object_type(&ui->forge, atom->type)
- && !(atom->type == ui->forge.Literal)
- && !(atom->type == ui->forge.Vector) )
- {
- ptr += strlen(ptr);
-
- sprintf(ptr, "</br>");
- }
- ptr += strlen(ptr);
-
- sprintf(ptr, CODE_POST);
-
- return ptr + strlen(ptr);
-}
-
-static char *
-_atom_item_label_get(void *data, Evas_Object *obj, const char *part)
-{
- UI *ui = evas_object_data_get(obj, "ui");
- const LV2_Atom *atom = data;
-
- if(!ui)
- return NULL;
-
- if(!strcmp(part, "elm.text"))
- {
- char *buf = ui->string_buf;
- char *ptr = buf;
- char *end = buf + STRING_BUF_SIZE;
-
- ptr = _atom_stringify(ui, ptr, end, 1, atom);
-
- return ptr
- ? strdup(buf)
- : NULL;
- }
-
- return NULL;
-}
-
-static char *
-_prop_item_label_get(void *data, Evas_Object *obj, const char *part)
-{
- UI *ui = evas_object_data_get(obj, "ui");
- const LV2_Atom_Property_Body *prop = data;
-
- if(!ui)
- return NULL;
-
- if(!strcmp(part, "elm.text"))
- {
- char *buf = ui->string_buf;
- char *ptr = buf;
- char *end = buf + STRING_BUF_SIZE;
-
- const char *key = _hash_get(ui, prop->key);
- const char *context = _hash_get(ui, prop->context);
-
- sprintf(ptr, URI("key ", "%s (%"PRIu32")"), key, prop->key);
- ptr += strlen(ptr);
-
- if(context)
- {
- sprintf(ptr, URI("</tab>context ", "%s (%"PRIu32")"), context, prop->context);
- ptr += strlen(ptr);
- }
-
- sprintf(ptr, "</br>");
- ptr += strlen(ptr);
-
- ptr = _atom_stringify(ui, ptr, end, 0, &prop->value);
-
- return ptr
- ? strdup(buf)
- : NULL;
- }
-
- return NULL;
-}
-
-static char *
-_seq_item_label_get(void *data, Evas_Object *obj, const char *part)
-{
- UI *ui = evas_object_data_get(obj, "ui");
- const LV2_Atom_Event *ev = data;
- const LV2_Atom *atom = &ev->body;
-
- if(!ui)
- return NULL;
-
- if(!strcmp(part, "elm.text"))
- {
- char *buf = ui->string_buf;
- char *ptr = buf;
- char *end = buf + STRING_BUF_SIZE;
-
- ptr = _atom_stringify(ui, ptr, end, 1, atom);
-
- return ptr
- ? strdup(buf)
- : NULL;
- }
-
- return NULL;
-}
-
static char *
_list_item_label_get(void *data, Evas_Object *obj, const char *part)
{
@@ -519,10 +182,11 @@ _list_item_label_get(void *data, Evas_Object *obj, const char *part)
}
static Evas_Object *
-_group_item_content_get(void *data, Evas_Object *obj, const char *part)
+_seq_item_content_get(void *data, Evas_Object *obj, const char *part)
{
UI *ui = evas_object_data_get(obj, "ui");
- const position_t *pos = data;
+ const LV2_Atom_Event *ev = data;
+ const LV2_Atom *atom = &ev->body;
if(!ui)
return NULL;
@@ -531,7 +195,7 @@ _group_item_content_get(void *data, Evas_Object *obj, const char *part)
{
char *buf = ui->string_buf;
- sprintf(buf, "<color=#000 font=Mono>0x%"PRIx64"</color>", pos->offset);
+ sprintf(buf, "<color=#bb0 font=Mono>%04"PRIi64"</color>", ev->time.frames);
Evas_Object *label = elm_label_add(obj);
if(label)
@@ -546,63 +210,6 @@ _group_item_content_get(void *data, Evas_Object *obj, const char *part)
{
char *buf = ui->string_buf;
- sprintf(buf, "<color=#0bb font=Mono>%"PRIu32"</color>", pos->nsamples);
-
- Evas_Object *label = elm_label_add(obj);
- if(label)
- {
- elm_object_part_text_set(label, "default", buf);
- evas_object_show(label);
- }
-
- return label;
- }
-
- return NULL;
-}
-
-static Evas_Object *
-_atom_item_content_get(void *data, Evas_Object *obj, const char *part)
-{
- UI *ui = evas_object_data_get(obj, "ui");
- const LV2_Atom *atom = data;
-
- if(!ui)
- return NULL;
-
- if(!strcmp(part, "elm.swallow.end"))
- {
- char *buf = ui->string_buf;
-
- sprintf(buf, "<color=#0bb font=Mono>%4"PRIu32"</color>", atom->size);
-
- Evas_Object *label = elm_label_add(obj);
- if(label)
- {
- elm_object_part_text_set(label, "default", buf);
- evas_object_show(label);
- }
-
- return label;
- }
-
- return NULL;
-}
-
-static Evas_Object *
-_prop_item_content_get(void *data, Evas_Object *obj, const char *part)
-{
- UI *ui = evas_object_data_get(obj, "ui");
- const LV2_Atom_Property_Body *prop = data;
- const LV2_Atom *atom = &prop->value;
-
- if(!ui)
- return NULL;
-
- if(!strcmp(part, "elm.swallow.end"))
- {
- char *buf = ui->string_buf;
-
sprintf(buf, "<color=#0bb font=Mono>%4"PRIu32"</color>", atom->size);
Evas_Object *label = elm_label_add(obj);
@@ -619,11 +226,10 @@ _prop_item_content_get(void *data, Evas_Object *obj, const char *part)
}
static Evas_Object *
-_seq_item_content_get(void *data, Evas_Object *obj, const char *part)
+_group_item_content_get(void *data, Evas_Object *obj, const char *part)
{
UI *ui = evas_object_data_get(obj, "ui");
- const LV2_Atom_Event *ev = data;
- const LV2_Atom *atom = &ev->body;
+ const position_t *pos = data;
if(!ui)
return NULL;
@@ -632,7 +238,7 @@ _seq_item_content_get(void *data, Evas_Object *obj, const char *part)
{
char *buf = ui->string_buf;
- sprintf(buf, "<color=#bb0 font=Mono>%04"PRIi64"</color>", ev->time.frames);
+ sprintf(buf, "<color=#000 font=Mono>0x%"PRIx64"</color>", pos->offset);
Evas_Object *label = elm_label_add(obj);
if(label)
@@ -647,7 +253,7 @@ _seq_item_content_get(void *data, Evas_Object *obj, const char *part)
{
char *buf = ui->string_buf;
- sprintf(buf, "<color=#0bb font=Mono>%4"PRIu32"</color>", atom->size);
+ sprintf(buf, "<color=#0bb font=Mono>%"PRIu32"</color>", pos->nsamples);
Evas_Object *label = elm_label_add(obj);
if(label)
@@ -668,131 +274,58 @@ _del(void *data, Evas_Object *obj)
free(data);
}
-static void
-_item_expand_request(void *data, Evas_Object *obj, void *event_info)
-{
- Elm_Object_Item *itm = event_info;
- UI *ui = data;
-
- elm_genlist_item_expanded_set(itm, EINA_TRUE);
-}
-
-static void
-_item_contract_request(void *data, Evas_Object *obj, void *event_info)
+// copyied and adapted from libsratom
+static inline char *
+_sratom_to_turtle(Sratom* sratom,
+ LV2_URID_Unmap* unmap,
+ const char* base_uri,
+ const SerdNode* subject,
+ const SerdNode* predicate,
+ uint32_t type,
+ uint32_t size,
+ const void* body)
{
- Elm_Object_Item *itm = event_info;
- UI *ui = data;
-
- elm_genlist_item_expanded_set(itm, EINA_FALSE);
-}
-
-static void
-_atom_expand(UI *ui, const LV2_Atom *atom, Evas_Object *obj, Elm_Object_Item *itm)
-{
- if(lv2_atom_forge_is_object_type(&ui->forge, atom->type))
- {
- const LV2_Atom_Object *atom_object = (const LV2_Atom_Object *)atom;
-
- LV2_ATOM_OBJECT_FOREACH(atom_object, prop)
- {
- Elm_Object_Item *itm2 = elm_genlist_item_append(ui->info, ui->itc_prop,
- prop, itm, ELM_GENLIST_ITEM_TREE, NULL, NULL);
- elm_genlist_item_select_mode_set(itm2, ELM_OBJECT_SELECT_MODE_DEFAULT);
- elm_genlist_item_expanded_set(itm2, EINA_TRUE);
- }
- }
- else if(atom->type == ui->forge.Tuple)
- {
- const LV2_Atom_Tuple *atom_tuple = (const LV2_Atom_Tuple *)atom;
-
- for(LV2_Atom *iter = lv2_atom_tuple_begin(atom_tuple);
- !lv2_atom_tuple_is_end(LV2_ATOM_BODY(atom_tuple), atom_tuple->atom.size, iter);
- iter = lv2_atom_tuple_next(iter))
- {
- Elm_Object_Item *itm2 = elm_genlist_item_append(ui->info, ui->itc_atom,
- iter, itm, ELM_GENLIST_ITEM_TREE, NULL, NULL);
- elm_genlist_item_select_mode_set(itm2, ELM_OBJECT_SELECT_MODE_DEFAULT);
- elm_genlist_item_expanded_set(itm2, EINA_TRUE);
- }
- }
- else if(atom->type == ui->forge.Vector)
- {
- const LV2_Atom_Vector *atom_vector = (const LV2_Atom_Vector *)atom;
-
- int num = (atom_vector->atom.size - sizeof(LV2_Atom_Vector_Body))
- / atom_vector->body.child_size;
- const uint8_t *body = LV2_ATOM_CONTENTS_CONST(LV2_Atom_Vector, atom_vector);
- for(int i=0; i<num; i++)
- {
- LV2_Atom *child = malloc(sizeof(LV2_Atom) + atom_vector->body.child_size);
- if(child)
- {
- child->size = atom_vector->body.child_size;
- child->type = atom_vector->body.child_type;
- memcpy(LV2_ATOM_BODY(child), body + i*child->size, child->size);
-
- Elm_Object_Item *itm2 = elm_genlist_item_append(ui->info, ui->itc_vec,
- child, itm, ELM_GENLIST_ITEM_TREE, NULL, NULL);
- elm_genlist_item_select_mode_set(itm2, ELM_OBJECT_SELECT_MODE_DEFAULT);
- elm_genlist_item_expanded_set(itm2, EINA_TRUE);
- }
- }
- }
- else if(atom->type == ui->forge.Sequence)
- {
- const LV2_Atom_Sequence *atom_seq = (const LV2_Atom_Sequence *)atom;
-
- LV2_ATOM_SEQUENCE_FOREACH(atom_seq, ev)
- {
- const LV2_Atom *child = &ev->body;
-
- Elm_Object_Item *itm2 = elm_genlist_item_append(ui->info, ui->itc_seq,
- ev, itm, ELM_GENLIST_ITEM_TREE, NULL, NULL);
- elm_genlist_item_select_mode_set(itm2, ELM_OBJECT_SELECT_MODE_DEFAULT);
- elm_genlist_item_expanded_set(itm2, EINA_TRUE);
- }
- }
-}
-
-static void
-_item_expanded(void *data, Evas_Object *obj, void *event_info)
-{
- Elm_Object_Item *itm = event_info;
- UI *ui = data;
-
- const Elm_Genlist_Item_Class *class = elm_genlist_item_item_class_get(itm);
- const void *udata = elm_object_item_data_get(itm);
-
- if(!udata)
- return;
-
- if( (class == ui->itc_sherlock) || (class == ui->itc_seq) )
- {
- const LV2_Atom_Event *ev = udata;
- const LV2_Atom *atom = &ev->body;
- _atom_expand(ui, atom, obj, itm);
- }
- else if(class == ui->itc_prop)
- {
- const LV2_Atom_Property_Body *prop = udata;
- const LV2_Atom *atom = &prop->value;
-
- _atom_expand(ui, atom, obj, itm);
- }
- else
- {
- const LV2_Atom *atom = udata;
- _atom_expand(ui, atom, obj, itm);
- }
-}
-
-static void
-_item_contracted(void *data, Evas_Object *obj, void *event_info)
-{
- Elm_Object_Item *itm = event_info;
- UI *ui = data;
-
- elm_genlist_item_subitems_clear(itm);
+ SerdURI buri = SERD_URI_NULL;
+ SerdNode base = serd_node_new_uri_from_string((uint8_t *)(base_uri), NULL, &buri);
+ SerdEnv* env = serd_env_new(&base);
+ SerdChunk str = { NULL, 0 };
+
+ serd_env_set_prefix_from_strings(env, (const uint8_t *)"rdf", NS_RDF);
+ serd_env_set_prefix_from_strings(env, (const uint8_t *)"xsd", NS_XSD);
+ serd_env_set_prefix_from_strings(env, (const uint8_t *)"lv2", (const uint8_t *)LV2_CORE_PREFIX);
+ serd_env_set_prefix_from_strings(env, (const uint8_t *)"midi", (const uint8_t *)LV2_MIDI_PREFIX);
+ serd_env_set_prefix_from_strings(env, (const uint8_t *)"atom", (const uint8_t *)LV2_ATOM_PREFIX);
+ serd_env_set_prefix_from_strings(env, (const uint8_t *)"units", (const uint8_t *)LV2_UNITS_PREFIX);
+ serd_env_set_prefix_from_strings(env, (const uint8_t *)"ui", (const uint8_t *)LV2_UI_PREFIX);
+
+ serd_env_set_prefix_from_strings(env, (const uint8_t *)"osc", NS_OSC);
+ serd_env_set_prefix_from_strings(env, (const uint8_t *)"xpress", NS_XPRESS);
+ serd_env_set_prefix_from_strings(env, (const uint8_t *)"spod", NS_SPOD);
+
+ SerdWriter* writer = serd_writer_new(
+ SERD_TURTLE,
+ (SerdStyle)(SERD_STYLE_ABBREVIATED |
+ SERD_STYLE_RESOLVED |
+ SERD_STYLE_CURIED),
+ env, &buri, serd_chunk_sink, &str);
+
+ // Write @prefix directives
+ serd_env_foreach(env,
+ (SerdPrefixSink)serd_writer_set_prefix,
+ writer);
+
+ sratom_set_sink(sratom, base_uri,
+ (SerdStatementSink)serd_writer_write_statement,
+ (SerdEndSink)serd_writer_end_anon,
+ writer);
+ sratom_write(sratom, unmap, SERD_EMPTY_S,
+ subject, predicate, type, size, body);
+ serd_writer_finish(writer);
+
+ serd_writer_free(writer);
+ serd_env_free(env);
+ serd_node_free(&base);
+ return (char*)serd_chunk_sink_finish(&str);
}
static void
@@ -802,23 +335,18 @@ _item_selected(void *data, Evas_Object *obj, void *event_info)
UI *ui = data;
const LV2_Atom_Event *ev = elm_object_item_data_get(itm);
- size_t len = sizeof(LV2_Atom_Event) + ev->body.size;
- LV2_Atom_Event *ev2 = malloc(len);
- if(!ev2)
- return;
-
- memcpy(ev2, ev, len);
-
- elm_genlist_clear(ui->info);
-
const LV2_Atom *atom = &ev->body;
- const bool is_expandable = _is_expandable(ui, atom->type);
- Elm_Object_Item *itm2 = elm_genlist_item_append(ui->info, ui->itc_sherlock,
- ev2, NULL, ELM_GENLIST_ITEM_TREE, NULL, NULL);
- elm_genlist_item_select_mode_set(itm2, ELM_OBJECT_SELECT_MODE_DEFAULT);
- if(is_expandable)
- elm_genlist_item_expanded_set(itm2, EINA_TRUE);
+ char *ttl = _sratom_to_turtle(ui->sratom, ui->unmap,
+ ui->base_uri, NULL, NULL,
+ atom->type, atom->size, LV2_ATOM_BODY_CONST(atom));
+ if(ttl)
+ {
+ enc.data = ui;
+ ttl_to_markup(ttl, NULL);
+
+ free(ttl);
+ }
}
static void
@@ -837,8 +365,6 @@ _clear_clicked(void *data, Evas_Object *obj, void *event_info)
{
UI *ui = data;
- if(ui->info)
- elm_genlist_clear(ui->info);
if(ui->list)
elm_genlist_clear(ui->list);
@@ -915,21 +441,15 @@ _content_get(UI *ui, Evas_Object *parent)
elm_object_part_content_set(panes, "left", ui->list);
}
- ui->info = elm_genlist_add(panes);
+ ui->info = elm_entry_add(ui->table);
if(ui->info)
{
- elm_genlist_homogeneous_set(ui->info, EINA_TRUE); // needef for lazy-loading
- elm_genlist_mode_set(ui->info, ELM_LIST_SCROLL);
- elm_genlist_block_count_set(ui->info, 64); // needef for lazy-loading
- elm_genlist_reorder_mode_set(ui->info, EINA_FALSE);
- elm_genlist_select_mode_set(ui->info, ELM_OBJECT_SELECT_MODE_DEFAULT);
- evas_object_data_set(ui->info, "ui", ui);
- evas_object_smart_callback_add(ui->info, "expand,request",
- _item_expand_request, ui);
- evas_object_smart_callback_add(ui->info, "contract,request",
- _item_contract_request, ui);
- evas_object_smart_callback_add(ui->info, "expanded", _item_expanded, ui);
- evas_object_smart_callback_add(ui->info, "contracted", _item_contracted, ui);
+ elm_entry_autosave_set(ui->info, EINA_FALSE);
+ elm_entry_entry_set(ui->info, "");
+ elm_entry_single_line_set(ui->info, EINA_FALSE);
+ elm_entry_scrollable_set(ui->info, EINA_TRUE);
+ elm_entry_editable_set(ui->info, EINA_FALSE);
+ elm_entry_cnp_mode_set(ui->info, ELM_CNP_MODE_PLAINTEXT);
evas_object_size_hint_weight_set(ui->info, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(ui->info, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_show(ui->info);
@@ -1038,6 +558,10 @@ _content_get(UI *ui, Evas_Object *parent)
}
}
+ ui->sratom = sratom_new(ui->map); //FIXME check
+ sratom_set_pretty_numbers(ui->sratom, false);
+ ui->base_uri = "file:///tmp/base";
+
return ui->table;
}
@@ -1102,78 +626,14 @@ instantiate(const LV2UI_Descriptor *descriptor, const char *plugin_uri,
ui->itc_group->func.del = _del;
}
- ui->itc_sherlock = elm_genlist_item_class_new();
- if(ui->itc_sherlock)
- {
- ui->itc_sherlock->item_style = "default_style";
- ui->itc_sherlock->func.text_get = _seq_item_label_get;
- ui->itc_sherlock->func.content_get = _seq_item_content_get;
- ui->itc_sherlock->func.state_get = NULL;
- ui->itc_sherlock->func.del = _del;
- }
-
- ui->itc_seq = elm_genlist_item_class_new();
- if(ui->itc_seq)
- {
- ui->itc_seq->item_style = "default_style";
- ui->itc_seq->func.text_get = _seq_item_label_get;
- ui->itc_seq->func.content_get = _seq_item_content_get;
- ui->itc_seq->func.state_get = NULL;
- ui->itc_seq->func.del = NULL;
- }
-
- ui->itc_prop = elm_genlist_item_class_new();
- if(ui->itc_prop)
- {
- ui->itc_prop->item_style = "default_style";
- ui->itc_prop->func.text_get = _prop_item_label_get;
- ui->itc_prop->func.content_get = _prop_item_content_get;
- ui->itc_prop->func.state_get = NULL;
- ui->itc_prop->func.del = NULL;
- }
-
- ui->itc_vec = elm_genlist_item_class_new();
- if(ui->itc_vec)
- {
- ui->itc_vec->item_style = "default_style";
- ui->itc_vec->func.text_get = _atom_item_label_get;
- ui->itc_vec->func.content_get = _atom_item_content_get;
- ui->itc_vec->func.state_get = NULL;
- ui->itc_vec->func.del = _del;
- }
-
- ui->itc_atom = elm_genlist_item_class_new();
- if(ui->itc_atom)
- {
- ui->itc_atom->item_style = "default_style";
- ui->itc_atom->func.text_get = _atom_item_label_get;
- ui->itc_atom->func.content_get = _atom_item_content_get;
- ui->itc_atom->func.state_get = NULL;
- ui->itc_atom->func.del = NULL;
- }
-
sprintf(ui->string_buf, "%s/omk_logo_256x256.png", bundle_path);
ui->logo_path = strdup(ui->string_buf);
- ui->uris.midi_MidiEvent = ui->map->map(ui->map->handle, LV2_MIDI__MidiEvent);
-
ui->uris.event_transfer = ui->map->map(ui->map->handle, LV2_ATOM__eventTransfer);
- ui->uris.time_position = ui->map->map(ui->map->handle, LV2_TIME__Position);
- ui->uris.time_barBeat = ui->map->map(ui->map->handle, LV2_TIME__barBeat);
- ui->uris.time_bar = ui->map->map(ui->map->handle, LV2_TIME__bar);
- ui->uris.time_beat = ui->map->map(ui->map->handle, LV2_TIME__beat);
- ui->uris.time_beatUnit = ui->map->map(ui->map->handle, LV2_TIME__beatUnit);
- ui->uris.time_beatsPerBar = ui->map->map(ui->map->handle, LV2_TIME__beatsPerBar);
- ui->uris.time_beatsPerMinute = ui->map->map(ui->map->handle, LV2_TIME__beatsPerMinute);
- ui->uris.time_frame = ui->map->map(ui->map->handle, LV2_TIME__frame);
- ui->uris.time_framesPerSecond = ui->map->map(ui->map->handle, LV2_TIME__framesPerSecond);
- ui->uris.time_speed = ui->map->map(ui->map->handle, LV2_TIME__speed);
-
ui->urids = eina_hash_int32_new(_hash_del);
// prepopulate hash table
- _hash_set(ui, ui->forge.Blank);
_hash_set(ui, ui->forge.Bool);
_hash_set(ui, ui->forge.Chunk);
_hash_set(ui, ui->forge.Double);
@@ -1184,26 +644,12 @@ instantiate(const LV2UI_Descriptor *descriptor, const char *plugin_uri,
_hash_set(ui, ui->forge.Object);
_hash_set(ui, ui->forge.Path);
_hash_set(ui, ui->forge.Property);
- _hash_set(ui, ui->forge.Resource);
_hash_set(ui, ui->forge.Sequence);
_hash_set(ui, ui->forge.String);
_hash_set(ui, ui->forge.Tuple);
_hash_set(ui, ui->forge.URI);
_hash_set(ui, ui->forge.URID);
_hash_set(ui, ui->forge.Vector);
-
- _hash_set(ui, ui->uris.midi_MidiEvent);
-
- _hash_set(ui, ui->uris.time_position);
- _hash_set(ui, ui->uris.time_barBeat);
- _hash_set(ui, ui->uris.time_bar);
- _hash_set(ui, ui->uris.time_beat);
- _hash_set(ui, ui->uris.time_beatUnit);
- _hash_set(ui, ui->uris.time_beatsPerBar);
- _hash_set(ui, ui->uris.time_beatsPerMinute);
- _hash_set(ui, ui->uris.time_frame);
- _hash_set(ui, ui->uris.time_framesPerSecond);
- _hash_set(ui, ui->uris.time_speed);
ui->widget = _content_get(ui, parent);
if(!ui->widget)
@@ -1228,21 +674,14 @@ cleanup(LV2UI_Handle handle)
eina_hash_free(ui->urids);
- if(ui->itc_atom)
- elm_genlist_item_class_free(ui->itc_atom);
- if(ui->itc_vec)
- elm_genlist_item_class_free(ui->itc_vec);
- if(ui->itc_prop)
- elm_genlist_item_class_free(ui->itc_prop);
- if(ui->itc_seq)
- elm_genlist_item_class_free(ui->itc_seq);
- if(ui->itc_sherlock)
- elm_genlist_item_class_free(ui->itc_sherlock);
if(ui->itc_list)
elm_genlist_item_class_free(ui->itc_list);
if(ui->itc_group)
elm_genlist_item_class_free(ui->itc_group);
+ if(ui->sratom)
+ sratom_free(ui->sratom);
+
free(ui);
}
@@ -1264,25 +703,11 @@ port_event(LV2UI_Handle handle, uint32_t i, uint32_t size, uint32_t urid,
if(seq->atom.size > sizeof(LV2_Atom_Sequence_Body)) // there are events
{
position_t *pos = malloc(sizeof(position_t));
- if(pos)
- {
- pos->offset = offset->body;
- pos->nsamples = nsamples->body;
-
- itm = elm_genlist_item_append(ui->list, ui->itc_group,
- pos, NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL);
- elm_genlist_item_select_mode_set(itm, ELM_OBJECT_SELECT_MODE_NONE);
- }
- }
-
- LV2_ATOM_SEQUENCE_FOREACH(seq, elmnt)
- {
- size_t len = sizeof(LV2_Atom_Event) + elmnt->body.size;
- LV2_Atom_Event *ev = malloc(len);
- if(!ev)
- continue;
+ if(!pos)
+ return;
- memcpy(ev, elmnt, len);
+ pos->offset = offset->body;
+ pos->nsamples = nsamples->body;
// check item count
if(n + 1 > COUNT_MAX)
@@ -1294,22 +719,37 @@ port_event(LV2UI_Handle handle, uint32_t i, uint32_t size, uint32_t urid,
}
else
{
- break;
+ return;
}
}
else if(elm_check_state_get(ui->autoblock))
{
- break;
+ return;
+ }
+
+ itm = elm_genlist_item_append(ui->list, ui->itc_group,
+ pos, NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL);
+ elm_genlist_item_select_mode_set(itm, ELM_OBJECT_SELECT_MODE_NONE);
+
+ LV2_ATOM_SEQUENCE_FOREACH(seq, elmnt)
+ {
+ size_t len = sizeof(LV2_Atom_Event) + elmnt->body.size;
+ LV2_Atom_Event *ev = malloc(len);
+ if(!ev)
+ continue;
+
+ memcpy(ev, elmnt, len);
+
+ Elm_Object_Item *itm2 = elm_genlist_item_append(ui->list, ui->itc_list,
+ ev, itm, ELM_GENLIST_ITEM_NONE, NULL, NULL);
+ elm_genlist_item_select_mode_set(itm2, ELM_OBJECT_SELECT_MODE_DEFAULT);
+ n++;
+
+ // scroll to last item
+ //elm_genlist_item_show(itm, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE);
}
-
- Elm_Object_Item *itm2 = elm_genlist_item_append(ui->list, ui->itc_list,
- ev, itm, ELM_GENLIST_ITEM_NONE, NULL, NULL);
- elm_genlist_item_select_mode_set(itm2, ELM_OBJECT_SELECT_MODE_DEFAULT);
- n++;
-
- // scroll to last item
- //elm_genlist_item_show(itm, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE);
}
+
if(seq->atom.size > sizeof(LV2_Atom_Sequence_Body))
_clear_update(ui, n); // only update if there where any events
diff --git a/common.h b/common.h
new file mode 100644
index 0000000..35dc3e9
--- /dev/null
+++ b/common.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2015 Hanspeter Portner (dev@open-music-kontrollers.ch)
+ *
+ * This is free software: you can redistribute it and/or modify
+ * it under the terms of the Artistic License 2.0 as published by
+ * The Perl Foundation.
+ *
+ * This source is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * Artistic License 2.0 for more details.
+ *
+ * You should have received a copy of the Artistic License 2.0
+ * along the source as a COPYING file. If not, obtain it from
+ * http://www.perlfoundation.org/artistic_license_2_0.
+ */
+
+#ifndef _COMMON_H
+#define _COMMON_H
+
+typedef void (*encoder_begin_t)(void *data);
+typedef void (*encoder_append_t)(const char *str, void *data);
+typedef void (*encoder_end_t)(void *data);
+typedef struct _moony_encoder_t moony_encoder_t;
+
+struct _moony_encoder_t {
+ encoder_begin_t begin;
+ encoder_append_t append;
+ encoder_end_t end;
+ void *data;
+};
+extern moony_encoder_t *encoder;
+
+void ttl_to_markup(const char *utf8, FILE *f);
+
+#endif
diff --git a/encoder.l b/encoder.l
new file mode 100644
index 0000000..0419ccf
--- /dev/null
+++ b/encoder.l
@@ -0,0 +1,254 @@
+/*
+ * Copyright (c) 2015 Hanspeter Portner (dev@open-music-kontrollers.ch)
+ *
+ * This is free software: you can redistribute it and/or modify
+ * it under the terms of the Artistic License 2.0 as published by
+ * The Perl Foundation.
+ *
+ * This source is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * Artistic License 2.0 for more details.
+ *
+ * You should have received a copy of the Artistic License 2.0
+ * along the source as a COPYING file. If not, obtain it from
+ * http://www.perlfoundation.org/artistic_license_2_0.
+ */
+
+%{
+#include <stdio.h>
+#include <string.h>
+
+#include <common.h>
+
+typedef enum _markup_type_t markup_type_t;
+typedef struct _markup_item_t markup_item_t;
+
+enum _markup_type_t {
+ MARKUP_CODE,
+ MARKUP_PREFIX,
+ MARKUP_SUBJECT,
+ MARKUP_PREDICATE,
+ MARKUP_NUMBER,
+ MARKUP_STRING,
+ MARKUP_URI
+};
+
+struct _markup_item_t {
+ const char *begin;
+ const char *end;
+};
+
+static const markup_item_t markup_items [] = {
+ [MARKUP_CODE] = {"font=Mono style=Plain color=#ffffff", "font"},
+ [MARKUP_PREFIX] = {"color=#cc00cc", "color"},
+ [MARKUP_SUBJECT] = {"color=#00cccc", "color"},
+ [MARKUP_PREDICATE] = {"color=#00cc00", "color"},
+ [MARKUP_NUMBER] = {"color=#0000cc", "color"},
+ [MARKUP_STRING] = {"color=#cc0000", "color"},
+ [MARKUP_URI] = {"color=#cccc00", "color"}
+};
+
+static void
+_add_plain(const char *content)
+{
+ encoder->append(content, encoder->data);
+}
+
+static void
+_add_singleton(const char *key)
+{
+ char buf [64];
+ sprintf(buf, "<%s/>", key);
+ encoder->append(buf, encoder->data);
+}
+
+static void
+_add_markup_begin(markup_type_t type)
+{
+ char buf [64];
+ sprintf(buf, "<%s>", markup_items[type].begin);
+ encoder->append(buf, encoder->data);
+}
+
+static void
+_add_markup_end(markup_type_t type)
+{
+ char buf [64];
+ sprintf(buf, "</%s>", markup_items[type].end);
+ encoder->append(buf, encoder->data);
+}
+
+static void
+_add_markup(markup_type_t type, const char *content)
+{
+ char buf [64];
+ sprintf(buf, "<%s>", markup_items[type].begin);
+ encoder->append(buf, encoder->data);
+ encoder->append(content, encoder->data);
+ sprintf(buf, "</%s>", markup_items[type].end);
+ encoder->append(buf, encoder->data);
+}
+
+enum {
+ TK_NONE,
+ TK_PREFIX,
+ TK_SUBJECT,
+ TK_PREDICATE,
+ TK_NUMBER,
+ TK_URI_IN,
+ TK_URI_OUT,
+ TK_URI_ERR,
+ TK_STRING_IN,
+ TK_STRING_OUT,
+ TK_STRING_ERR,
+ TK_WHITESPACE,
+ TK_RAW,
+ TK_TAB,
+ TK_NEWLINE,
+ TK_NAME,
+ TK_BADCHAR
+};
+
+%}
+
+%option reentrant noyywrap
+
+w [ \v\a]+
+name [_a-zA-Z@][_a-zA-Z0-9\.]*
+n [0-9]+
+exp [Ee][+-]?{n}
+number ({n}|{n}[.]{n}){exp}?
+eol [\n\r]
+
+%x XSTRING
+%x XURI
+
+%%
+
+{w} return TK_WHITESPACE;
+"\t" return TK_TAB;
+{eol} return TK_NEWLINE;
+"<" BEGIN(XURI); return TK_URI_IN;
+\" BEGIN(XSTRING); return TK_STRING_IN;
+{name}: return TK_SUBJECT;
+"@prefix" return TK_PREFIX;
+"a" return TK_PREFIX;
+{name} return TK_PREDICATE;
+{number} return TK_NUMBER;
+. return TK_RAW;
+
+<XURI>
+{
+ ">" BEGIN(0); return TK_URI_OUT;
+ {eol} BEGIN(0); return TK_URI_ERR;
+ . return TK_RAW;
+}
+
+<XSTRING>
+{
+ \\\" return TK_RAW;
+ \" BEGIN(0); return TK_STRING_OUT;
+ {eol} BEGIN(0); return TK_STRING_ERR;
+ . return TK_RAW;
+}
+
+%%
+
+void
+ttl_to_markup(const char *utf8, FILE *f)
+{
+ yyscan_t scanner;
+ YY_BUFFER_STATE buf;
+
+ enclex_init(&scanner);
+ if(utf8)
+ {
+ buf = enc_scan_string(utf8, scanner);
+ }
+ else if(f)
+ {
+ encset_in(f, scanner);
+ buf = enc_create_buffer(NULL, YY_BUF_SIZE, scanner);
+ }
+ else
+ {
+ enclex_destroy(scanner);
+ return;
+ }
+
+ encoder->begin(encoder->data);
+ _add_markup_begin(MARKUP_CODE);
+
+ for(int tok=enclex(scanner); tok; tok=enclex(scanner))
+ {
+ const char *txt = encget_text(scanner);
+ switch(tok)
+ {
+ case TK_PREFIX:
+ _add_markup(MARKUP_PREFIX, txt);
+ break;
+
+ case TK_NUMBER:
+ _add_markup(MARKUP_NUMBER, txt);
+ break;
+
+ case TK_URI_IN:
+ _add_markup_begin(MARKUP_URI);
+ _add_plain("&lt;");
+ break;
+ case TK_URI_OUT:
+ _add_plain("&gt;");
+ _add_markup_end(MARKUP_URI);
+ break;
+ case TK_URI_ERR:
+ _add_markup_end(MARKUP_URI);
+ _add_singleton("br");
+ break;
+
+ case TK_STRING_IN:
+ _add_markup_begin(MARKUP_STRING);
+ _add_plain("\"");
+ break;
+ case TK_STRING_OUT:
+ _add_plain("\"");
+ _add_markup_end(MARKUP_STRING);
+ break;
+ case TK_STRING_ERR:
+ _add_markup_end(MARKUP_STRING);
+ _add_singleton("br");
+ break;
+
+ case TK_NEWLINE:
+ _add_singleton("br");
+ break;
+
+ case TK_BADCHAR:
+ break;
+
+ case TK_TAB:
+ _add_plain(" ");
+ break;
+
+ case TK_SUBJECT:
+ _add_markup(MARKUP_SUBJECT, txt);
+ break;
+ case TK_PREDICATE:
+ _add_markup(MARKUP_PREDICATE, txt);
+ break;
+
+ case TK_NAME:
+ case TK_WHITESPACE:
+ case TK_RAW:
+ default:
+ _add_plain(txt);
+ break;
+ }
+ }
+
+ _add_markup_end(MARKUP_CODE);
+ encoder->end(encoder->data);
+
+ enc_delete_buffer(buf, scanner);
+ enclex_destroy(scanner);
+}
diff --git a/midi_inspector_eo.c b/midi_inspector_eo.c
index 0418192..4ca99c3 100644
--- a/midi_inspector_eo.c
+++ b/midi_inspector_eo.c
@@ -804,25 +804,11 @@ port_event(LV2UI_Handle handle, uint32_t i, uint32_t size, uint32_t urid,
if(seq->atom.size > sizeof(LV2_Atom_Sequence_Body)) // there are events
{
position_t *pos = malloc(sizeof(position_t));
- if(pos)
- {
- pos->offset = offset->body;
- pos->nsamples = nsamples->body;
+ if(!pos)
+ return;
- itm = elm_genlist_item_append(ui->list, ui->itc_group,
- pos, NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL);
- elm_genlist_item_select_mode_set(itm, ELM_OBJECT_SELECT_MODE_NONE);
- }
- }
-
- LV2_ATOM_SEQUENCE_FOREACH(seq, elmnt)
- {
- size_t len = sizeof(LV2_Atom_Event) + elmnt->body.size;
- LV2_Atom_Event *ev = malloc(len);
- if(!ev)
- continue;
-
- memcpy(ev, elmnt, len);
+ pos->offset = offset->body;
+ pos->nsamples = nsamples->body;
// check item count
if(n + 1 > COUNT_MAX)
@@ -834,22 +820,36 @@ port_event(LV2UI_Handle handle, uint32_t i, uint32_t size, uint32_t urid,
}
else
{
- break;
+ return;
}
}
else if(elm_check_state_get(ui->autoblock))
{
- break;
+ return;
}
-
- Elm_Object_Item *itm2 = elm_genlist_item_append(ui->list, ui->itc_midi,
- ev, itm, ELM_GENLIST_ITEM_NONE, NULL, NULL);
- elm_genlist_item_select_mode_set(itm2, ELM_OBJECT_SELECT_MODE_DEFAULT);
- elm_genlist_item_expanded_set(itm2, EINA_FALSE);
- n++;
+
+ itm = elm_genlist_item_append(ui->list, ui->itc_group,
+ pos, NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL);
+ elm_genlist_item_select_mode_set(itm, ELM_OBJECT_SELECT_MODE_NONE);
+
+ LV2_ATOM_SEQUENCE_FOREACH(seq, elmnt)
+ {
+ size_t len = sizeof(LV2_Atom_Event) + elmnt->body.size;
+ LV2_Atom_Event *ev = malloc(len);
+ if(!ev)
+ continue;
+
+ memcpy(ev, elmnt, len);
- // scroll to last item
- //elm_genlist_item_show(itm, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE);
+ Elm_Object_Item *itm2 = elm_genlist_item_append(ui->list, ui->itc_midi,
+ ev, itm, ELM_GENLIST_ITEM_NONE, NULL, NULL);
+ elm_genlist_item_select_mode_set(itm2, ELM_OBJECT_SELECT_MODE_DEFAULT);
+ elm_genlist_item_expanded_set(itm2, EINA_FALSE);
+ n++;
+
+ // scroll to last item
+ //elm_genlist_item_show(itm, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE);
+ }
}
if(seq->atom.size > sizeof(LV2_Atom_Sequence_Body))
diff --git a/osc_inspector_eo.c b/osc_inspector_eo.c
index 1c6f669..5526293 100644
--- a/osc_inspector_eo.c
+++ b/osc_inspector_eo.c
@@ -884,25 +884,11 @@ port_event(LV2UI_Handle handle, uint32_t i, uint32_t size, uint32_t urid,
if(seq->atom.size > sizeof(LV2_Atom_Sequence_Body)) // there are events
{
position_t *pos = malloc(sizeof(position_t));
- if(pos)
- {
- pos->offset = offset->body;
- pos->nsamples = nsamples->body;
+ if(!pos)
+ return;
- itm = elm_genlist_item_append(ui->list, ui->itc_group,
- pos, NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL);
- elm_genlist_item_select_mode_set(itm, ELM_OBJECT_SELECT_MODE_NONE);
- }
- }
-
- LV2_ATOM_SEQUENCE_FOREACH(seq, elmnt)
- {
- size_t len = sizeof(LV2_Atom_Event) + elmnt->body.size;
- LV2_Atom_Event *ev = malloc(len);
- if(!ev)
- continue;
-
- memcpy(ev, elmnt, len);
+ pos->offset = offset->body;
+ pos->nsamples = nsamples->body;
// check item count
if(n + 1 > COUNT_MAX)
@@ -914,25 +900,39 @@ port_event(LV2UI_Handle handle, uint32_t i, uint32_t size, uint32_t urid,
}
else
{
- break;
+ return;
}
}
else if(elm_check_state_get(ui->autoblock))
{
- break;
+ return;
}
- const LV2_Atom_Object *obj = (const LV2_Atom_Object *)&ev->body;
- Elm_Object_Item *itm2 = elm_genlist_item_append(ui->list, ui->itc_packet,
- ev, itm, ELM_GENLIST_ITEM_TREE, NULL, NULL);
- elm_genlist_item_select_mode_set(itm2, ELM_OBJECT_SELECT_MODE_DEFAULT);
- elm_genlist_item_expanded_set(itm2, EINA_FALSE);
- n++;
-
- // scroll to last item
- //elm_genlist_item_show(itm, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE);
+ LV2_ATOM_SEQUENCE_FOREACH(seq, elmnt)
+ {
+ size_t len = sizeof(LV2_Atom_Event) + elmnt->body.size;
+ LV2_Atom_Event *ev = malloc(len);
+ if(!ev)
+ continue;
+
+ memcpy(ev, elmnt, len);
+
+ const LV2_Atom_Object *obj = (const LV2_Atom_Object *)&ev->body;
+ Elm_Object_Item *itm2 = elm_genlist_item_append(ui->list, ui->itc_packet,
+ ev, itm, ELM_GENLIST_ITEM_TREE, NULL, NULL);
+ elm_genlist_item_select_mode_set(itm2, ELM_OBJECT_SELECT_MODE_DEFAULT);
+ elm_genlist_item_expanded_set(itm2, EINA_FALSE);
+ n++;
+
+ // scroll to last item
+ //elm_genlist_item_show(itm, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE);
+ }
+
+ itm = elm_genlist_item_append(ui->list, ui->itc_group,
+ pos, NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL);
+ elm_genlist_item_select_mode_set(itm, ELM_OBJECT_SELECT_MODE_NONE);
}
-
+
if(seq->atom.size > sizeof(LV2_Atom_Sequence_Body))
_clear_update(ui, n); // only update if there where any events
}
diff --git a/sherlock.h b/sherlock.h
index 62a730d..ed487d3 100644
--- a/sherlock.h
+++ b/sherlock.h
@@ -25,6 +25,7 @@
#include "lv2/lv2plug.in/ns/ext/midi/midi.h"
#include "lv2/lv2plug.in/ns/ext/time/time.h"
#include "lv2/lv2plug.in/ns/ext/urid/urid.h"
+#include "lv2/lv2plug.in/ns/extensions/units/units.h"
#include "lv2/lv2plug.in/ns/extensions/ui/ui.h"
#include "lv2/lv2plug.in/ns/lv2core/lv2.h"
diff --git a/sherlock.ttl b/sherlock.ttl
index 2067de8..8d01e23 100644
--- a/sherlock.ttl
+++ b/sherlock.ttl
@@ -23,6 +23,7 @@
@prefix urid: <http://lv2plug.in/ns/ext/urid#> .
@prefix patch: <http://lv2plug.in/ns/ext/patch#> .
+@prefix xpress: <http://open-music-kontrollers.ch/lv2/xpress#> .
@prefix osc: <http://open-music-kontrollers.ch/lv2/osc#> .
@prefix lic: <http://opensource.org/licenses/> .
@prefix omk: <http://open-music-kontrollers.ch/ventosus#> .
@@ -34,6 +35,11 @@ osc:Event
rdfs:subClassOf atom:Object ;
rdfs:label "OSC Event (Bundle or Message)" .
+xpress:Message
+ a rdfs:Class ,
+ rdfs:Datatype ;
+ rdfs:subClassOf atom:Atom .
+
# Maintainer
omk:me
a foaf:Person ;
@@ -65,7 +71,8 @@ sherlock:atom_inspector
atom:supports midi:MidiEvent ,
time:Position ,
patch:Message ,
- osc:Event ;
+ osc:Event ,
+ xpress:Message ;
lv2:index 0 ;
lv2:symbol "control_in" ;
lv2:name "Control In" ;
@@ -78,7 +85,8 @@ sherlock:atom_inspector
atom:supports midi:MidiEvent ,
time:Position ,
patch:Message ,
- osc:Event ;
+ osc:Event ,
+ xpress:Message ;
lv2:index 1 ;
lv2:symbol "control_out" ;
lv2:name "Control Out" ;