From 6b894cab3b6e3c1ba966025a32dd0d2cd057ae7c Mon Sep 17 00:00:00 2001 From: mescalinum Date: Fri, 25 Sep 2009 22:49:47 +0000 Subject: add editor: old code, new black magic (comm protocol still to implement) svn path=/trunk/externals/ffext/; revision=12452 --- composer/Editor.cpp | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 composer/Editor.cpp (limited to 'composer/Editor.cpp') diff --git a/composer/Editor.cpp b/composer/Editor.cpp new file mode 100644 index 0000000..c56d853 --- /dev/null +++ b/composer/Editor.cpp @@ -0,0 +1,74 @@ +#include "Editor.hpp" +#include "Track.hpp" +#include "Song.hpp" + +#include +#include + +#include + +#include "editor_tk.cpp" +static const int editor_tk_len = sizeof(editor_tk) / sizeof(editor_tk[0]); + +using std::cerr; +using std::endl; +using std::string; + +static char hexnibble(unsigned int i) +{ + i &= 0xf; + return (i < 0xa) ? ('0' + i) : ('a' + i - 0xa); +} + +static const char* urlencode(char c) +{ + static char buf[4]; + buf[0] = '%'; + buf[1] = hexnibble((c & 0xf0) >> 4); + buf[2] = hexnibble(c & 0xf); + buf[3] = '\0'; + return &buf[0]; +} + +void Editor::uploadCode() +{ + sys_gui("proc Xeval {c {d {}}} {switch $c {begin {set ::Xeval_map {}; for {set i 0} {$i < 256} {incr i} {lappend ::Xeval_map \%[format \%02x $i] [format \%c $i]}; set ::Xeval_data {}} data {append ::Xeval_data [string map $::Xeval_map $d]\\n} end {uplevel #0 $::Xeval_data; unset ::Xeval_map; unset ::Xeval_data}}}\n"); + sys_gui("Xeval begin\n"); + for(int i = 0; i < editor_tk_len; i++) + { + string s = "Xeval data {"; + string l = editor_tk[i]; + for(int j = 0; j < l.length(); j++) + { + if(isalnum(l[j])) s.append(1, l[j]); + else s += string(urlencode(l[j])); + } + s += "}\n"; + sys_gui(const_cast(s.c_str())); + } + sys_gui("Xeval end\n"); +} + +void Editor::init(t_track_proxy *x) +{ + uploadCode(); + sys_vgui("pd::composer::init %s %s %s %d %s %d\n", + x->editor_recv->s_name, + x->track->getSong()->getName().c_str(), + x->track->getName().c_str(), + 16, + "NULL", + 1); +} + +void Editor::openWindow(t_track_proxy *x) +{ + x->editor_open = 1; + sys_vgui("pd::composer::openWindow %s\n", x->editor_recv->s_name); +} + +void Editor::closeWindow(t_track_proxy *x) +{ + x->editor_open = 0; + sys_vgui("pd::composer::closeWindow %s\n", x->editor_recv->s_name); +} -- cgit v1.2.1