follow my heart...
分类: C/C++
2006-09-21 13:00:06
CH编程环境ChSciTe的配置for windows[原创]
1、安装CH环境,如安装在目录d:\ch下,用户可在中下载
2、下载chscite软件,它是基于windows下的ch集成开发环境。http://www.download-by.net/development/source-editors/183563,chscite,dl.html 或 进行下载
3、安装chscite后系统并不能调试,要将d:\ch下的ch.exe及chs.exe拷到windows\system32下面
4、正常编译程序。
附:英文资料(不好意思,比较忙,所以没时间翻)
Editing and Executing C/Ch/C++ Programs
ChSciTE is an Integrated
Development Environment for developing C/Ch/C++ programs in Ch. Text
editing in ChSciTE works similarly to most Macintosh or Windows editors
such as Notepad with the added feature of automatic syntax styling. The
user interface can be in one of 30 local languages such as German,
French, Chinese, and Korea. ChSciTE can hold multiple files in memory
at one time but only one file will be visible. ChSciTE allows up to 20
files to be in memory at once. Rectangular regions of text can be
selected in ChSciTE by holding down the Alt key on Windows or the Ctrl
key on GTK+ while dragging the mouse over the text.
There are two panes in ChSciTE, the editing pane and the output pane. The output pane is located either to the below of the editing pane or on the right. Initially it is of zero size, but it can be made larger by dragging the divider between it and the editing pane.
The Options | Vertical Split command can be used to move the output pane on the right of the editing pane.
With Ch installed on the machine, the edited program can readily be executed in ChSciTE like in other IDE such as Microsoft Visual Studio. The source files are executed interpretively without compilation. The output from the program are directed into the output pane.
The First Example of Editing and Executing a Program with Output.
For example, open a new document, type:
#i nclude
int main() {
printf("Hello, world!\n");
return 0;
}
as that document's text. The program should now appear coloured with syntax highlighting as shown in Figure 1.
Figure 1: Program hello.c
Save the document as hello.c as shown in Figure 2.
Figure 2: Save program hello.c
The program hello.c in CHHOME/demos/bin/hello.c, where CHHOME is the home directory for Ch such as C:/Ch in Windows, can also be loaded using File | Open command.
Perform the Tools | Run as shown in Figure 3 to executing the program hello.c.
Figure 3: Executing program hello.c
Instead of performing the Tools | Run command, pressing function key F5 will have the same effect of executing the program.
The output window will be made visible if it is not already visible and will show:
>ch -u hello.c
Hello, world!
>Exit code: 0
as displayed in Figure 4.
Figure 4: The output from executing program hello.c
The first blue line is from ChSciTE showing the command it will use to run the program. The black line is the output from running the Ch program. The last blue line is from ChSciTE showing that the program has finished and displaying its exit code. An exit code of zero indicates a successful run.
ChSciTE understands the error messages produced by Ch. To see this, add a mistake to the Ch file by changing the line
printf("Hello, world");
to
printf("Hello, world";
Perform the Tools | Run the modified program. The results should look below
>ch -u hello.c
ERROR: missing ')'
ERROR: syntax error before or at line 4 in file hello.c
==>: printf("Hello, world\n";
BUG: printf("Hello, world\n"; <== ???
ERROR: cannot excute command 'hello.c'
>Exit code: 1
as shown in Figure 5.
Figure 5: The error line in output from executing program hello.c
Click the line in output with red color in Figure 5, the line with incorrect syntax will be highlightd as shown in Figure 6.
Figure 6: Finding the error line in output from executing program hello.c
While it is easy to see where the problem is in this simple case, when a file is larger the Tools | Next Message command can be used to view each of the reported errors. Upon performing Tools | Next Message, the first error message in the output pane and the appropriate line in the editing pane are highlighted with a yellow background, The caret is moved to this line and the pane is scrolled if needed to show the line. ChSciTE now looks like in Figure 6.
ChSciTE understands both the file name and line number parts of error messages in most cases so can open another file (such as a header file) if errors were caused by that file. This feature may not work where the file name is complicated by containing spaces or ".."
If command execution has failed and is taking too long to complete then the Tools | Stop Executing command can be used.
On Windows, ChSciTE defaults to executing tools as command line programs. Executing a GUI program in this mode results in that program being run without displaying a window. The command.subsystem option can be used to define tools that run in GUI mode. The default subsystem, 0, is for command line programs, 1 is for programs which create their own windows, and 2 is for using the ShellExecute call. To run a GUI prgram such as OpenGL and Windows, use Tools | Launch Ch Shell command to launch a Ch shell. Run the GUI program in this shell.
On GTK+, the default subsystem 0 executes the tool and waits for it to finish, redirecting output to the output pane and subsystem 2 executes the tool in the background.
Setup Paths and Finding Commands in Ch
When a command is typed
into a prompt of a command shell for execution, the command shell will
search the command in prespecified directories. In Ch shell, the system
variable _path of string type contains the directories to be searched
for the command. Each directory is separated by a semicolon inside the
string _path. When a command shell is launched, the system variable
_path contains some default search paths. The user can add new
directories to the search paths for the command shell by string
function stradd() which adds arguments of string type and returns it as
a new string. For example, in Unix, to include the directory
/home/myaccount/bin in the search paths for a command, the following
statement
_path = stradd(_path, "/home/myaccount/bin;");
in startup file .chrc in the user's home directory needs to be
added. As another example, to include the directory C:/c99 in Windows
in the search paths for a command, statement
_path = stradd(_path, "C:/c99;");
in startup file _chrc in the user's home directory, such as
C:/_chrc, needs to be added. You may copy a sample startup file to your
home directory by executing the following command in a comman shell.
ch -d
The local Ch initialization startup file _chrc for Windows and .chrc
for Unix in the user's home directory can be opened for editing by
ChSciTE editor as shown in Figure 8.
Figure 8: Open the local Ch initialization startup file for editing.
The Second Example with Input.
This example will show how to run
a C/Ch/C++ program/script that requires the user to input data. Type in
the code as shown in Figure 9. During execution, this code should ask
the user to "Please intput a number" and then cause the system to
output "Yout input number is" and the number that the user inputted.
Figure 9: A program with input from the user.
During the exection of the program, the user will be prompted to
input a number as shown in Figure 10. The user then must type in a
number in the same pane for both input and output. Both input number of
56 and output are shown in Figure 10.
Figure 10: Executing the program with input and ouput.
The Third Example with Plotting in Ch.
This example will show
how to run a C/Ch/C++ program/script that creates a plot. Type in the
code as shown in Figure 11. During execution, this code should create a
new screen with a plot as shown in Figure 13. The plotting functions
are avaiable in Ch Professional Edition. This example utilized
computation arrays to store the data used for plotting.
Figure 11: A plotting program.
Figure 12: The output of the plotting program.
The Fourth Example with Command Line Options.
This example will
show how to run a C/Ch/C++ program/script with command line option.
Type in the code as shown in Figure 13. This program will accept the
command line options and print them out. The option parameters are
setup in View|Parameters menu as shown in Figure 14 and Figure 15 The
output from execution of this program with command line options is
displayed in Figure 16
Figure 13: A program for handling command line option.
Figure 14: Setup command line options.
Figure 15: Setup command line options.
Figure 16: Executing the program with command line options.
Buffers
ChSciTE has 20 buffers each containing a file. The
Buffers menu can be used to switch between buffers, either by selecting
the file name or using the Previous (F6) and Next (Shift+F6) commands.
When all the buffers contain files, then opening a new file causes a buffer to be reused which may require a file to be saved. In this case an alert is displayed to ensure the user wants the file saved.
Sessions
A session is a list of file names. You can save a
complete set of your currently opened buffers as a session for fast
batch-loading in the future. Sessions are stored as plain text files
with the extension ".ses".
Use File | Load Session and File | Save Session to load/save sessions. You can turn on/off "last session autoloading" using ChSciTE properties variable "save.session".
By default, session management is turned on.
Loading previously saved session will close your currently opened buffers. However you will not loose your edits, because you will be asked to save unsaved buffers first.
Opening a specific file from command line overrides "save.session" variable state. When you start ChSciTE loading a specific file from command line last session will not restore even if "save.session" variable is set to "1". This makes "save.session" safe to use - you will never open a couple of files when you are trying to open just one, specific file.
Languages Understood by ChSciTE
ChSciTE currently is able to syntax style these languages (* denotes support for folding):
C/Ch/C++*
CSS*
HTML*
Make
SQL and PLSQL
TeX and LaTeX
XML*
Language
settings are determined from the file extension but this can be changed
by selecting another language from the Language menu. The language menu
can be changed with the menu.language property.
Find and Replace
ChSciTE has options to allow searching for
words, regular expressions, matching case, in the reverse direction,
wrapping around the end of the document. C style backslash escapes
which are listed in the command line arguments section, may be used to
search and replace control characters. Replacements can be made
individually, over the current selection or over the whole file. When
regular expressions are used tagged subexpressions can be used in the
replacement text. Regular expressions will not match across a line end.
ChSciTE supports basic regular expressions with tagging.
Keyboard commands
ChSciTE uses the default key bindings defined
in Scintilla, so keyboard commands in ChSciTE mostly follow common
Windows and GTK+ conventions. All move keys (arrows, page up/down, home
and end) allows to extend or reduce the stream selection when holding
the Shift key, and the rectangular selection when holding the Shift and
Alt keys. Some keys may not be available with some national keyboards
or because they are taken by the system such as by a window manager on
GTK+. The user.shortcuts setting may be used to assign a key to a
function. Note that Home key behaviour is changed by the vc.home.key
option. Keyboard equivalents of menu commands are listed in the menus.
Some less common commands with no menu equivalent are:
Run C/Ch/C++ program. F5
Parse C/Ch/C++ program. F7
Launch Ch shell. Ctrl+F7
Magnify text size. Ctrl+Keypad+
Reduce text size. Ctrl+Keypad-
Restore text size to normal. Ctrl+Keypad/
Cycle through recent files. Ctrl+Tab
Indent block. Tab
Dedent block. Shift+Tab
Delete to start of word. Ctrl+BackSpace
Delete to end of word. Ctrl+Delete
Delete to start of line. Ctrl+Shift+BackSpace
Delete to end of line. Ctrl+Shift+Delete
Go to start of document. Ctrl+Home
Extend selection to start of document. Ctrl+Shift+Home
Go to start of display line. Alt+Home
Extend selection to start of display line. Alt+Shift+Home
Go to end of document. Ctrl+End
Extend selection to end of document. Ctrl+Shift+End
Go to end of display line. Alt+End
Extend selection to end of display line. Alt+Shift+End
Expand or contract a fold point. Ctrl+Keypad*
Create or delete a bookmark. Ctrl+F2
Go to next bookmark. F2
Select to next bookmark. Alt+F2
Find selection. Ctrl+F3
Find selection backwards. Ctrl+Shift+F3
Scroll up. Ctrl+Up
Scroll down. Ctrl+Down
Line cut. Ctrl+L
Line copy. Ctrl+Shift+T
Line delete. Ctrl+Shift+L
Line transpose with previous. Ctrl+T
Line duplicate. Ctrl+D
Find matching preprocessor conditional, skipping nested ones. Ctrl+K
Select to matching preprocessor conditional. Ctrl+Shift+K
Find matching preprocessor conditional backwards, skipping nested ones. Ctrl+J
Select to matching preprocessor conditional backwards. Ctrl+Shift+J
Previous paragraph. Shift extends selection. Ctrl+[
Next paragraph. Shift extends selection. Ctrl+]
Previous word. Shift extends selection. Ctrl+Left
Next word. Shift extends selection. Ctrl+Right
Previous word part. Shift extends selection Ctrl+/
Next word part. Shift extends selection. Ctrl+\
Abbreviations
To use an abbreviation, type it and use the Expand
Abbreviation command or the Ctrl+B key. The abbreviation is replaced by
an expansion defined in the Abbreviations file. You can open the
Abbreviations file with a command in the Options menu and add
abbreviations.
Each line in the files looks like "abbreviation=expansion".
The
abbreviations names can have any character (except perhaps control
chars, surely for CR and LF), including high Ascii chars (accented
chars).
Names have properties files limits: they cannot start with
sharp (#) or space or tab (but can have spaces inside); and they cannot
have '=' character inside.
Abbreviations names are limited to 32 characters. It is probably enough for abbreviations...
An expansion may contain new line characters indicated by '\n'
and a caret position indicated by the '|' character. To include a
literal '|' character, use '||'.
Some simple examples are included in the distributed Abbreviations file.
When
expanding, the names don't need to be separated from the previous text.
Ie. if you define '‰' as 'é', you can expand it inside a
word.
If a name is the ending of another one, only the shorter will
ever be expanded. Ie. if you define 'ring' and 'gathering', the later
will see only the 'ring' part expanded.
Folding
ChSciTE supports folding for many languages (see the
list of languages understood by ChSciTE for more information.) Fold
points are based upon indentation for C and on counting braces for the
other languages. The fold point markers can be clicked to expand and
contract folds. Ctrl+Shift+Click in the fold margin will expand or
contract all the top level folds. Ctrl+Click on a fold point to toggle
it and perform the same operation on all children. Shift+Click on a
fold point to show all children.
Command parameters and prompting
ChSciTE has 4 properties $(1)
.. $(4) which can be used to run commands with changeable parameters.
To set the parameter values, use the View | Parameters command to view
the modeless Parameters dialog which shows the current values of these
parameters and allows setting new values. The accelerator keys for the
main window remain active while this dialog is displayed, so it can be
used to rapidly run a command several times with different parameters.
Alternatively, a command can be made to display the modal Parameters
dialog when executed by starting the command with a '*' which is
otherwise ignored. If the modeless Parameters dialog is already
visible, then the '*' is ignored.
Encodings
ChSciTE will automatically detect the encoding scheme
used for Unicode files that start with a Byte Order Mark (BOM). The
UTF-8 and UCS-2 encodings are recognized including both Little Endian
and Big Endian variants of UCS-2.
UTF-8 files will also be recognised when they contain a coding
cookie on one of the first two lines. A coding cookie looks similar to
"coding: utf-8" ("coding" followed by ':' or '=', optional whitespace,
optional quote, "utf-8") and is normally contained in a comment:
# -*- coding: utf-8 -*-
For XML there is a declaration:
For other encodings set the code.page and character.set properties.
ChSciTE in other languages
ChSciTE can be and has been translated into other languages.