212 lines
7.5 KiB
HTML
212 lines
7.5 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<html>
|
|
<head><title>Factor plugin</title>
|
|
|
|
<style>
|
|
.fancy-heading { background: #c0d0ff; border: 1px solid #2040ff; }
|
|
div.fancy-heading { padding: 1px; margin: 0px 0px 3px 0px; }
|
|
.nice-box {
|
|
padding: 4px;
|
|
border-width: 1px;
|
|
border-style: dashed;
|
|
}
|
|
.syntax0 {
|
|
color: #000000;
|
|
}
|
|
.syntax1 {
|
|
color: #cc0000;
|
|
}
|
|
.syntax2 {
|
|
color: #ff8400;
|
|
}
|
|
.syntax3 {
|
|
color: #6600cc;
|
|
}
|
|
.syntax4 {
|
|
color: #cc6600;
|
|
}
|
|
.syntax5 {
|
|
color: #ff0000;
|
|
}
|
|
.syntax6 {
|
|
color: #9966ff;
|
|
}
|
|
.syntax7 {
|
|
background: #ffffcc;
|
|
color: #ff0066;
|
|
}
|
|
.syntax8 {
|
|
color: #006699;
|
|
font-weight: bold;
|
|
}
|
|
.syntax9 {
|
|
color: #009966;
|
|
font-weight: bold;
|
|
}
|
|
.syntax10 {
|
|
color: #0099ff;
|
|
font-weight: bold;
|
|
}
|
|
.syntax11 {
|
|
color: #66ccff;
|
|
font-weight: bold;
|
|
}
|
|
.syntax12 {
|
|
color: #02b902;
|
|
}
|
|
.syntax13 {
|
|
color: #ff00cc;
|
|
}
|
|
.syntax14 {
|
|
color: #cc00cc;
|
|
}
|
|
.syntax15 {
|
|
color: #9900cc;
|
|
}
|
|
.syntax16 {
|
|
color: #6600cc;
|
|
}
|
|
.syntax17 {
|
|
color: #0000ff;
|
|
}
|
|
.syntax18 {
|
|
color: #000000;
|
|
font-weight: bold;
|
|
}
|
|
.gutter {
|
|
background: #dbdbdb;
|
|
color: #000000;
|
|
}
|
|
.gutterH {
|
|
background: #dbdbdb;
|
|
color: #666699;
|
|
}
|
|
</style>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
|
|
<h1 align="center">Factor plugin</h1>
|
|
|
|
<p>Factor is a programming language with postfix syntax. The Factor plugin for <a href="http://www.jedit.org">jEdit</a> makes for a more pleasant programming experience -- it allows you to navigate Factor source very rapidly, running unit tests and reloading code with ease. Word definitions become a pleasure to write with on the fly parsing, completion, and stack effect checking. For information on Factor itself, including extensive documentation in PDF format, see the Factor web site: <a href="http://factor.sourceforge.net">http://factor.sourceforge.net</a>. </p>
|
|
|
|
The <code>Factor.jar</code> file shipped with the Factor distribution can then be placed in <code>$HOME/.jedit/jars/</code> and loaded by jEdit.<p>
|
|
|
|
<h2 class="fancy-heading">Getting started</h2>
|
|
|
|
<h3>Hooking jEdit up with Factor</h3>
|
|
|
|
<p>The Factor plugin needs to communicate with a running Factor instance. This is configured in <b>Plugins</b>><b>Plugin Options</b>><b>Factor</b>. There are two options when it comes to setting up the external instance:</p>
|
|
|
|
<ul>
|
|
<li>The plugin can launch the Factor process itself. In this case, you supply a full path to the Factor runtime, as well as a path to the image file.</li>
|
|
<li>The plugin can also connect to a Factor instance running on another machine. In this case, you will need to supply the host name and port number. Then you must launch Factor on the remote machine and enter the phrase following in the listener:</li>
|
|
</ul>
|
|
|
|
<pre class="nice-box">USE: telnetd
|
|
9999 telnetd</pre>
|
|
|
|
<p>If you want to use a port number other than 9999, you must specify it above.</p>
|
|
|
|
<h3>Keyboard shortcuts</h3>
|
|
|
|
<p>You can install a set of keyboard shortcuts for the various commands provided by the Factor plugin by invoking <b>Plugins</b>><b>Factor</b>><b>Install default keymap</b>. These shortcuts are all prefixed with <b>A+</b>. While they are not set by the default, the remainder of the guide refers to these shortcuts.</p>
|
|
|
|
<h2 class="fancy-heading">Live environment</h2>
|
|
|
|
<h3>The listener</h3>
|
|
|
|
<p>The plugin embeds a Factor listener in the Console for quick testing of code snippets while editing. The listener supports styled text and hyperlinks; for example when using the <code>see</code> word to look at a word definition.</p>
|
|
|
|
<p>The embedded listener can be accessed by selecting the <b>Factor</b> shell in the Console plugin. The following commands can be used to send text from jEdit to the listener:</p>
|
|
|
|
<ul>
|
|
<li><b>Run current file (A+f f)</b></li>
|
|
<li><b>Evaluate selection (A+f e s)</b></li>
|
|
<li><b>Evaluate word definition (A+f e e)</b></li>
|
|
</ul>
|
|
|
|
<img class="nice-box" src="listener.png">
|
|
|
|
<h3>Instant parsing</h3>
|
|
|
|
<p>Factor files are parsed in a background thread and checked for errors, using the framework provided by the SideKick plugin. Errors are underlined in the text area (and listed in the <b>ErrorList</b> plugin window). Words are looked up in the external Factor instance, and you are notified of typos immediately.</p>
|
|
|
|
<img class="nice-box" src="error.png">
|
|
|
|
<p>The stack effect of the word at the caret is shown in the status bar.</p>
|
|
|
|
<img class="nice-box" src="status.png">
|
|
|
|
<p>The <b>Plugins</b>><b>SideKick</b>><b>Structure Browser</b> displays a list of all words defined in the current buffer:</p>
|
|
|
|
<img class="nice-box" src="word-list.png">
|
|
|
|
<h2 class="fancy-heading">Code comprehension</h2>
|
|
|
|
<h3>Navigation</h3>
|
|
|
|
<p>The navigation features enable you to move around in a project and locate definitions.</p>
|
|
|
|
<p>The <b>Edit word (A+f g)</b> command opens a dialog box where the name of a word can be typed -- while the word is being typed, the possible completions is instantly updated, and selecting one opens the source file containing the definition of that word:</p>
|
|
|
|
<img class="nice-box" src="edit-word.png">
|
|
|
|
<p>To be able to edit definitions of standard library words, add a phrase like the following to your <code>$HOME/.factor-rc</code>:</p>
|
|
|
|
<pre class="nice-box"><SPAN CLASS="syntax13">"</SPAN><SPAN CLASS="syntax13">/home/slava/Factor/</SPAN><SPAN CLASS="syntax13">"</SPAN> <SPAN CLASS="syntax13">"</SPAN><SPAN CLASS="syntax13">resource-path</SPAN><SPAN CLASS="syntax13">"</SPAN> set
|
|
</PRE>
|
|
|
|
<p>The <b>Edit word at caret (A+f j)</b> command opens the source file containing the definition of the word at the caret.</p>
|
|
|
|
<p>The <b>See word at caret (A+f w)</b> command displays a popup word definition.</p>
|
|
|
|
<img class="nice-box" src="see.png">
|
|
|
|
<h3>Cross-referencing</h3>
|
|
|
|
<p>The <b>Word usages at caret (A+f u)</b> command displays a list of words that use a word.</p>
|
|
|
|
<img class="nice-box" src="usages.png">
|
|
|
|
<p> Clicking on words in the listener shows a popup menu with various useful actions.</p>
|
|
|
|
<img class="nice-box" src="usages-menu.png">
|
|
|
|
<p>Here we see the result of selecting <b>See</b>.</p>
|
|
|
|
<img class="nice-box" src="usages-see.png">
|
|
|
|
<p>The <b>Infer word at caret (A+f i i)</b> command shows a popup with the inferred stack effect. Note that not all words have an inferred stack effect. This command is great for debugging!</p>
|
|
|
|
<img class="nice-box" src="infer.png">
|
|
|
|
<h2 class="fancy-heading">Coding time-savers</h2>
|
|
|
|
<h3>Vocabularies</h3>
|
|
|
|
<p>Factor words are separated into vocabularies, and each source file must list which vocabularies it uses. A common error is a missing <code>USING:</code> declaration. The <b>Use word at caret (A+f u)</b> command searches for the word at the caret in all vocabularies, and adds a <code>USE:</code> declaration for the vocabulary to the start of the source file -- in this case, <code>ifte</code> is found in the <code>kernel</code> vocabulary, and the parse error instantly goes away:</p>
|
|
|
|
<img class="nice-box" src="word-use.png">
|
|
|
|
<p>Invoking <b>Plugins</b>><b>SideKick</b>><b>Show Completion Popup</b> displays a popup of possible completions for the word at the caret -- bind this to <code>C+SPACE</code> for quick access. Inserting a call to a word via a completion popup automatically adds a <code>USING:</code> declaration, if necessary.</p>
|
|
|
|
<img class="nice-box" src="complete.png">
|
|
|
|
<h3>Automated factoring</h3>
|
|
|
|
<p>The <b>Extract word</b> command can only be invoked if there is a selection. It asks for a new word name, replaces the selection with a call to the word, and adds a new colon definition directly above the current definition.</p>
|
|
|
|
<p>Here, some text is selected:</p>
|
|
|
|
<img class="nice-box" src="extract-before.png">
|
|
|
|
<p>Now, <b>Extract word (A+f x)</b> is invoked, and a new word name is entered:</p>
|
|
|
|
<img class="nice-box" src="extract-after.png">
|
|
|
|
</body>
|
|
</html>
|