Commit 6ba17a54 authored by Hanspeter Portner's avatar Hanspeter Portner

redesign sherlock#atom_inspector.

* show turtle instead of atom object genlist
* fix detection of maximal amount of events
parent bfbbc743
......@@ -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})
......
This diff is collapsed.
/*
* 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
/*
* 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);
}
......@@ -804,26 +804,12 @@ 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)
{
if(!pos)
return;
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;
memcpy(ev, elmnt, len);
// check item count
if(n + 1 > COUNT_MAX)
{
......@@ -834,14 +820,27 @@ 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_midi,
ev, itm, ELM_GENLIST_ITEM_NONE, NULL, NULL);
elm_genlist_item_select_mode_set(itm2, ELM_OBJECT_SELECT_MODE_DEFAULT);
......@@ -851,6 +850,7 @@ port_event(LV2UI_Handle handle, uint32_t i, uint32_t size, uint32_t urid,
// 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
......
......@@ -884,26 +884,12 @@ 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)
{
if(!pos)
return;
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;
memcpy(ev, elmnt, len);
// check item count
if(n + 1 > COUNT_MAX)
{
......@@ -914,14 +900,23 @@ 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;
}
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);
......@@ -933,6 +928,11 @@ port_event(LV2UI_Handle handle, uint32_t i, uint32_t size, uint32_t urid,
//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
}
......
......@@ -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"
......
......@@ -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" ;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment