aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Hanspeter Portner <dev@open-music-kontrollers.ch>2017-05-12 16:41:38 +0200
committerGravatar Hanspeter Portner <dev@open-music-kontrollers.ch>2017-05-12 16:41:38 +0200
commit5472cd0601cf5a29f17950e647d5e05073b80a24 (patch)
treee84dcde1fb1bc931973e5d200068dea0c0ff70bf
parent787823255df6bcba20a89c46443efed28ba27610 (diff)
downloadmoony.lv2-5472cd0601cf5a29f17950e647d5e05073b80a24.zip
moony.lv2-5472cd0601cf5a29f17950e647d5e05073b80a24.tar.gz
moony.lv2-5472cd0601cf5a29f17950e647d5e05073b80a24.tar.bz2
moony.lv2-5472cd0601cf5a29f17950e647d5e05073b80a24.tar.xz
api/nk: deprecate sending of selection/line.
* users should use code injection instead which will preserve state.
-rw-r--r--VERSION2
-rw-r--r--api/api.c17
-rw-r--r--include/moony.h2
-rw-r--r--plugin/nk_ui.c105
4 files changed, 3 insertions, 123 deletions
diff --git a/VERSION b/VERSION
index b335ae2..4311696 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.21.377
+0.21.379
diff --git a/api/api.c b/api/api.c
index b8bee1b..f460655 100644
--- a/api/api.c
+++ b/api/api.c
@@ -1229,7 +1229,6 @@ moony_init(moony_t *moony, const char *subject, double sample_rate,
moony->voice_map = &voice_map_fallback;
moony->uris.moony_code = moony->map->map(moony->map->handle, MOONY_CODE_URI);
- moony->uris.moony_selection = moony->map->map(moony->map->handle, MOONY_SELECTION_URI);
moony->uris.moony_error = moony->map->map(moony->map->handle, MOONY_ERROR_URI);
moony->uris.moony_trace = moony->map->map(moony->map->handle, MOONY_TRACE_URI);
moony->uris.moony_panic = moony->map->map(moony->map->handle, MOONY_PANIC_URI);
@@ -2335,22 +2334,6 @@ moony_in(moony_t *moony, const LV2_Atom_Sequence *control, LV2_Atom_Sequence *no
moony_trace(moony, "waking worker failed");
}
}
- else if( (property->body == moony->uris.moony_selection) && (value->type == forge->String) )
- {
- // we do not do any stash, apply and restore for selections
-
- // load chunk
- const char *str = LV2_ATOM_BODY_CONST(value);
- if(luaL_dostring(L, str)) // failed loading chunk
- {
- moony_error(moony);
- }
- else // succeeded loading chunk
- {
- moony->error[0] = 0x0; // reset error flag
- moony->error_out = true;
- }
- }
else if( (property->body == moony->uris.moony_editorHidden) && (value->type == forge->Bool) )
{
atomic_store_explicit(&moony->editor_hidden, ((const LV2_Atom_Bool *)value)->body, memory_order_release);
diff --git a/include/moony.h b/include/moony.h
index 2da3b45..cf4321a 100644
--- a/include/moony.h
+++ b/include/moony.h
@@ -76,7 +76,6 @@
#define MOONY_PREFIX MOONY_URI"#"
#define MOONY_CODE_URI MOONY_URI"#code"
-#define MOONY_SELECTION_URI MOONY_URI"#selection"
#define MOONY_ERROR_URI MOONY_URI"#error"
#define MOONY_TRACE_URI MOONY_URI"#trace"
#define MOONY_STATE_URI MOONY_URI"#state"
@@ -235,7 +234,6 @@ struct _moony_t {
struct {
LV2_URID moony_code;
- LV2_URID moony_selection;
LV2_URID moony_error;
LV2_URID moony_trace;
LV2_URID moony_panic;
diff --git a/plugin/nk_ui.c b/plugin/nk_ui.c
index c87f147..2b122aa 100644
--- a/plugin/nk_ui.c
+++ b/plugin/nk_ui.c
@@ -157,7 +157,6 @@ struct _browser_t {
struct nk_image default_file;
struct nk_image checked;
struct nk_image run_all;
- struct nk_image run_selection;
struct nk_image import_from;
struct nk_image export_to;
struct nk_image refresh;
@@ -210,7 +209,6 @@ struct _plughandle_t {
LV2_URID patch_subject;
LV2_URID patch_sequenceNumber;
LV2_URID moony_code;
- LV2_URID moony_selection;
LV2_URID moony_error;
LV2_URID moony_trace;
LV2_URID moony_panic;
@@ -488,7 +486,6 @@ file_browser_init(browser_t *browser, int return_hidden, int return_lua_only,
browser->icons.default_file = icon_load(data, "envelope.png");
browser->icons.checked = icon_load(data, "checked.png");
browser->icons.run_all = icon_load(data, "next.png");
- browser->icons.run_selection = icon_load(data, "sort.png");
browser->icons.import_from = icon_load(data, "upload.png");
browser->icons.export_to = icon_load(data, "download.png");
browser->icons.refresh = icon_load(data, "reload.png");
@@ -517,7 +514,6 @@ file_browser_free(browser_t *browser,
icon_unload(data, browser->icons.default_file);
icon_unload(data, browser->icons.checked);
icon_unload(data, browser->icons.run_all);
- icon_unload(data, browser->icons.run_selection);
icon_unload(data, browser->icons.import_from);
icon_unload(data, browser->icons.export_to);
icon_unload(data, browser->icons.refresh);
@@ -982,15 +978,6 @@ _clear_error(plughandle_t *handle)
}
static void
-_submit_selection(plughandle_t *handle, const char *sel, uint32_t sz)
-{
- _clear_error(handle);
-
- _patch_set(handle, handle->moony_selection,
- sz, handle->forge.String, sel);
-}
-
-static void
_submit_all(plughandle_t *handle)
{
_clear_error(handle);
@@ -1003,82 +990,6 @@ _submit_all(plughandle_t *handle)
}
static void
-_submit_line(plughandle_t *handle)
-{
- uint32_t newlines = 0;
- uint32_t from = 0;
- for(int i = 0; i < handle->editor.cursor; i++) // count newlines
- {
- if(handle->code[i] == '\n')
- {
- newlines += 1;
- from = i + 1;
- }
- }
-
- // create selection with prefixed newlines
- struct nk_str *str = &handle->editor.string;
- const char *code = nk_str_get_const(str);
- const int code_sz = nk_str_len_char(str);
- char *end = memchr(code + from, '\n', code_sz);
- const uint32_t to = end ? end - code : code_sz;
- const uint32_t len = to - from;
- if(len > 0)
- {
- const uint32_t sz = newlines + len + 1;
- char *sel = calloc(sz, sizeof(char));
- if(sel)
- {
- memset(sel, '\n', newlines);
- memcpy(sel + newlines, code + from, len);
-
- _submit_selection(handle, sel, sz);
-
- free(sel);
- }
- }
-}
-
-static void
-_submit_sel(plughandle_t *handle)
-{
- struct nk_str *str = &handle->editor.string;
- const char *code = nk_str_get_const(str);
-
- const uint32_t len = handle->editor.select_end - handle->editor.select_start;
- if(len > 0)
- {
- uint32_t newlines = 0;
- for(int i = 0; i < handle->editor.select_start; i++) // count newlines
- {
- if(code[i] == '\n')
- newlines += 1;
- }
-
- const uint32_t sz = newlines + len + 1;
- char *sel = calloc(sz, sizeof(char));
- if(sel)
- {
- memset(sel, '\n', newlines);
- memcpy(sel + newlines, code + handle->editor.select_start, len);
-
- _submit_selection(handle, sel, sz);
-
- free(sel);
- }
- }
-}
-
-static void
-_submit_line_or_sel(plughandle_t *handle)
-{
- if(handle->editor.select_end == handle->editor.select_start)
- _submit_line(handle);
- else
- _submit_sel(handle);
-}
-
-static void
_clear_log(plughandle_t *handle)
{
for(int i = 0; i < handle->n_trace; i++)
@@ -2273,9 +2184,7 @@ _expose(struct nk_context *ctx, struct nk_rect wbounds, void *data)
&handle->editor, nk_filter_default);
if(state & NK_EDIT_COMMITED)
{
- if(has_control_down)
- _submit_line_or_sel(handle);
- else if(has_shift_down)
+ if(has_shift_down)
_submit_all(handle);
has_commited = true;
@@ -2319,7 +2228,7 @@ _expose(struct nk_context *ctx, struct nk_rect wbounds, void *data)
nk_push_scissor(canv, old_clip);
}
- nk_layout_row_dynamic(ctx, dy, 5);
+ nk_layout_row_dynamic(ctx, dy, 4);
if(_tooltip_visible(ctx))
nk_tooltip(ctx, "Shift-Enter");
@@ -2335,15 +2244,6 @@ _expose(struct nk_context *ctx, struct nk_rect wbounds, void *data)
nk_style_pop_style_item(ctx);
if(_tooltip_visible(ctx))
- nk_tooltip(ctx, "Ctrl-Enter");
- nk_style_push_style_item(ctx, &ctx->style.button.normal, has_control_enter && has_commited
- ? nk_style_item_color(nk_default_color_style[NK_COLOR_BUTTON_ACTIVE])
- : nk_style_item_color(nk_default_color_style[NK_COLOR_BUTTON]));
- if(nk_button_image_label(ctx, handle->browser.icons.run_selection, "Line/sel.", NK_TEXT_RIGHT))
- _submit_line_or_sel(handle);
- nk_style_pop_style_item(ctx);
-
- if(_tooltip_visible(ctx))
nk_tooltip(ctx, "Ctrl-N");
nk_style_push_style_item(ctx, &ctx->style.button.normal, has_control_n
? nk_style_item_color(nk_default_color_style[NK_COLOR_BUTTON_ACTIVE])
@@ -2792,7 +2692,6 @@ instantiate(const LV2UI_Descriptor *descriptor, const char *plugin_uri,
handle->patch_subject = handle->map->map(handle->map->handle, LV2_PATCH__subject);
handle->patch_sequenceNumber = handle->map->map(handle->map->handle, LV2_PATCH__sequenceNumber);
handle->moony_code = handle->map->map(handle->map->handle, MOONY_CODE_URI);
- handle->moony_selection = handle->map->map(handle->map->handle, MOONY_SELECTION_URI);
handle->moony_error = handle->map->map(handle->map->handle, MOONY_ERROR_URI);
handle->moony_trace = handle->map->map(handle->map->handle, MOONY_TRACE_URI);
handle->moony_panic = handle->map->map(handle->map->handle, MOONY_PANIC_URI);