Quick Guide of TurtleEdit
The main window of TurtleEdit consists of two panes. Upper pane is for editing texts or programming codes; lower pane is used to display outputs from your code as a dumb terminal. The lower pane is not editable. You can open and edit an only single file at the same time.
The functionality of this editor is just minimal; you will not find it any difficult to use. Please note that there is no way to turn off the display of line-number nor line-wrap feature. All multibyte characters are displayed with orange boxes to be distinguishable from ASCII characters.
Launching external programs
Just by pressing
and buttons, you can execute pre-registered external programs, such as compilers and compiled executables. To use this feature, you need to register the locations of those executables beforehand. Open Settings in Run menu, and configure the command lines in text fields.
In the text field named "Compile command", describe how source codes to be compiled.
In the command line, %f
is replaced by the file name being edited,
%b
the base name of the file (for example, "foo" is set if file name is "foo.c";,
%d
directory name where the opened file is stored,
%c
directory name where TurtleEdit locates, and
%h
home directory, respectively.
To include white space in the command line intentionally, quote that part with a pair of single quotation marks, or
place %s
at the position of a white space.
At the time when the content in editing pane is saved, the location of the file is set as current working directory.
To compile C codes, for instance, Compile command field will be
cc %f -lm
In the Command for execution text field, describe how to execute compiled codes, which is activated when
button pressed. A typical example would be./a.out
In the Additional exec PATH field, give a list of additional items for PATH environmental variable separated by ":". (In the Windows version, use semicolon instead of colon as a separator.)
Typical settings are preset so that you can choose one of them from Preset values.
"Path to TurtleField" and "Auto Launch" are used only when you want to use TurtleField graphics software from TurtleEdit. You need not to configure these items in usual cases.
Choose appropriate character code and fonts.
By pressing
button, all the settings are saved and will be restored in next time.You may use TurtleEdit as a frontend for LaTeX. Assuming that LaTeX is installed in /opt/local/bin, settings will be
Compile command: /opt/local/bin/latex %f Command for execution: /opt/local/bin/xdvi %b Additional exec PATH: /opt/local/bin
where the additional PATH name /opt/local/bin/opt is effective when /local/bin/xdvi launch other executables.
TIPS
In Windows, use backslashes, not slashes, for the delimiter in path names like "C:\Users\bob".
To launch an external terminal emulator with a shell, you can specify the "Command for execution" field as
Mac: open -a Terminal command_name KDE(Linux): konsole -e command_name Windows: CMD command_name
To describe command lines including white space(s) such like
/bin/bash -c "dvipdfmx file_name.dvi && acroread file_name.pdf"
use single quotation marks like
/bin/bash -c 'dvipdfmx %b.dvi&&acroread %b.pdf'
In the Command for execution text field.
%b
is replaced by the part of file name where [dot]extension is omitted.
Program coding with TurtleEdit
After settings were done, TurtleEdit can be used as an extremely simple IDE (Integrated Development Environment).
- Write source code in editing pane
- Save the code to file (use File menu)
- Press button. Error messages will be displayed in the console(output) pane, if any.
- After compilation succeeds, press button. If the code behaves in some unexpected manner, press button to terminate the code.
Before pressing "ruby -cw %f"
would be a nice choice.
An alternative way to solve the buffering issue is described here.
If you are writing a code with console input, please take care about the buffering of i/o. For example, if you executed the following code
#include <stdio.h> main(){ int x ; printf("x? ") ; scanf("%d",&x) ; printf("x=%d\n",x) ; }
prompt "x?" will not appear in the expected timing because of buffering. You need to modify this code as
printf("x? ") ; fflush(stdout) ; scanf("%d",&x) ;
to flush buffered data, or call setbuf() function before calling printf() as
setbuf(stdout,NULL) ; printf("x? ") ; scanf("%d",&x) ;
to prohibit buffering.
Notes
To input data from keyboard, click the console(output) pane first. When the pane is activated and becomes ready, you see a red cursor on it. Then, type keyboard.
The data size that executable codes can output to the console pane is limited to prevent unexpected errors such as infinite looping. The maximum data size of about 1 mega characters.
Text processing using regular expressions
You can perform filtering of the text data in the editing pane with regular expressions. Choose RegEx Filter in Filter menu, another window show up. Input regular expression, then press [OK]. Matched data will be displayed in the console pane.
For the format of regular expression, check manuals and documents of Java. Note that, by default, dot does not match end-of-line.
You can choose one of the three behaviors of filtering:
- Matched string: only matched strings are output.
- Matched line: only matched lines are output.
- Lines containing pattern.
If Line number is checked, outputs in the console pane include line numbers.
Using RegEx Replace in Filter menu, you can replace the matched pattern to other string, and the result is displayed in the console pane. Filtering does NOT change text in editing pane. The n-th group in the regular expression that you described is associated with $n ($1,$2,..,$9) in the string to replace.
Some common filtering functions, including sort, uniq, tr, are registered in the Filtering menu.
For further complicated functionality, select External command in Filter menu to launch external program such as awk.
Using Swap buffers in the bottom of Filter menu, you can exchange the contents in upper and lower panes. This functionality might be useful to apply several filtering rules in sequential steps.