2 summary:: Emacs user interfaces
5 The Emacs interface actually has some nice options for user interfaces as well. Here are some examples:
13 // create a key action for the buffer:
15 p.defineKey( "hello", { "hey there".postln; } );
17 // type hello on the window and look at the postbuffer
20 p.defineKey( "hey there", { "hello".postln; } );
22 // type hey there and look at the postbuffer
25 // put some text in the buffer:
27 p.insert( "this is a really interesting text to read in the buffer" );
36 p.button( [ "on", "off", "in between" ], { |v| v.postln; } );
39 // make a button with a different look:
40 p.button( [ "on", "off", "in between" ], { |v| v.postln; }, "******", "+++++" );
43 // create a close button:
45 // clicking it will close the buffer!
49 p.editableField( "write something here", "like this?", { |v| v.postln; } );
52 // moving the cursor around in the buffer:
53 p.gotoBob; // beginning
55 p.goto( 5 ); // go to fifth position
57 // making it a sclang-mode buffer to write code in:
58 Emacs.evalLispExpression( p.use( [ 'sclang-mode' ] ).asLispString );
65 p = EmacsBuffer.new; // args: name
68 // making a number box
69 n = EmacsNumber.new( p, "number box", [0,5].asSpec, { |v| v.postln; } ); // args: buffer, tag/label, spec, action
73 x = EmacsButton( p, [ "on", "off", "in between" ], { |v| v.postln; }, "******", "+++++" );
74 // args: buffer, states, action, prefix, suffix
77 t = EmacsText( p, "hello", 30 ); // args: buffer, string, size, align
81 t = EmacsText( p, "helloooo", 30, \right ); // args: buffer, string, size, align
84 e = EmacsEditableField( p, "edit field", "edit me" ).action_( { |v| v.postln; } );
87 b = EmacsPushButton( p, "hello" ).action_( { "do it".postln; } );
90 // you can disable things:
96 And last but not least, it provides a class browser:
98 EmacsClassBrowser.new( EmacsBuffer );