1 /// The Emacs interface actually has some nice options for user interfaces as well. Here are some examples:
9 // create a key action for the buffer:
11 p.defineKey( "hello", { "hey there".postln; } );
13 // type hello on the window and look at the postbuffer
16 p.defineKey( "hey there", { "hello".postln; } );
18 // type hey there and look at the postbuffer
21 // put some text in the buffer:
23 p.insert( "this is a really interesting text to read in the buffer" );
32 p.button( [ "on", "off", "in between" ], { |v| v.postln; } );
35 // make a button with a different look:
36 p.button( [ "on", "off", "in between" ], { |v| v.postln; }, "******", "+++++" );
39 // create a close button:
41 // clicking it will close the buffer!
45 p.editableField( "write something here", "like this?", { |v| v.postln; } );
48 // moving the cursor around in the buffer:
49 p.gotoBob; // beginning
51 p.goto( 5 ); // go to fifth position
53 // making it a sclang-mode buffer to write code in:
54 Emacs.evalLispExpression( p.use( [ 'sclang-mode' ] ).asLispString );
61 p = EmacsBuffer.new; // args: name
64 // making a number box
65 n = EmacsNumber.new( p, "number box", [0,5].asSpec, { |v| v.postln; } ); // args: buffer, tag/label, spec, action
69 x = EmacsButton( p, [ "on", "off", "in between" ], { |v| v.postln; }, "******", "+++++" );
70 // args: buffer, states, action, prefix, suffix
73 t = EmacsText( p, "hello", 30 ); // args: buffer, string, size, align
77 t = EmacsText( p, "helloooo", 30, \right ); // args: buffer, string, size, align
80 e = EmacsEditableField( p, "edit field", "edit me" ).action_( { |v| v.postln; } );
83 b = EmacsPushButton( p, "hello" ).action_( { "do it".postln; } );
86 // you can disable things:
93 // and last but not least, it provides a class browser:
95 EmacsClassBrowser.new( EmacsBuffer );