Skip to content

EmacsWidget documentation (new file) #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions HelpSource/Classes/EmacsWidget.schelp
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
TITLE:: EmacsWidget
SUMMARY:: Abstract superclass for Emacs widgets
CATEGORIES:: Frontends>Emacs
RELATED:: Classes/EmacsBuffer, Classes/Emacs

DESCRIPTION::
An abstract class for Emacs widgets such as link::Classes/EmacsButton::, link::Classes/EmacsPushButton::, link::Classes/EmacsNumber::, link::Classes/EmacsEditableField:: and link::Classes/EmacsText::.

CLASSMETHODS::

METHOD:: idmap
An link::Classes/Array:: of widget's IDs. Size of the array is fixed to 1024.

INSTANCEMETHODS::

METHOD:: type

returns:: The type of widget.

METHOD:: buffer

returns:: The link::Classes/EmacsBuffer::.

METHOD:: id

returns:: The ID of widget.

METHOD:: enabled
Gets/sets the state of the widget.
ARGUMENT:: argValue
A link::Classes/Boolean::.
ARGUMENT:: handler
A link::Classes/Function:: which will be executed when changing state.

subsection::Example
code::
(
p = EmacsBuffer.new; // create a buffer:
p.front; // show the buffer:

EmacsPushButton(p, "Close").action={p.free};

2.do({p.gotoBob; p.newline}); // add some space above

// make 8 numberboxes in a column
n = Array.fill(8, { |i| var e; p.gotoBob; p.newline; e = EmacsNumber.new( p, "Box "++i, [0,999999].asSpec, { |v| v.postln; }, value: 100.rand, size: 8 ); e });

3.do({p.gotoBob; p.newline}); // add some space above

p.gotoBob; // goto very begining

t = EmacsText( p, "SuperCollider", 30, \left); // args: buffer, string, size, align

1.do({p.gotoBob; p.newline}); // space ..
p.gotoBob;

EmacsEditableField( p, "Password", "0123" ).action_( { |v| t.string = v; } );

2.do({p.gotoBob; p.newline}); // space ..
p.gotoBob;

EmacsPushButton( p, "calculate" ).action_( { f.() } ); // make a button, attach a funcion to it

// super warp 9 function
f = { fork{200.do({n.choose.value = 999999.rand + 1; t.string = t.string.scramble;0.01.wait; })} };
)


// Erase widgets / clear buffer
Emacs.evalLispExpression(p.use(['save-current-buffer', ['set-buffer', ['get-buffer', p.name]], ['let', [['inhibit-read-only', 't']], ['with-silent-modifications', ['remove-overlays'], ['erase-buffer']]]]).asLispString)

EmacsText( p, "Enjoy", 30);

p.free
::