Scintilla includes features especially useful when editing and debugging source code.These includes syntax styling,error indicators,code indication and call tips.The selection can contain markers like those used in debuggers to indicate the breakpoint and the current line.Scintilla provides a huge amount of user customization .The user can make even more styling choices then other editors.including propotional fonts,bold and italics,multiple foreground and background colors and fonts.
You can find its full information at .
Here,I'll demo how to use it in MFC dialog program ,for more detailed usage ,please turn to its website given above.
First,download scintilla src package and extract it somewhere as you like.Open visual c++ 6.0 and create a dialog-based application using App Wizard.Add include subfolder into ur project as well as the SciLexer.dll.
Let's go on.Add a HMODULE member to your CWinApp derived class,suppose it's m_hScitilla.In InitInstance function,add :
1 m_hScitilla = LoadLibrary( " SciLexer.dll); 2 if (m_hScitilla == NULL){ 3 // Quit ?? As ur will! 4 }
Remember to free the library in ExitInstance funciton:
1 if (m_hScitilla != NULL){ 2 FreeLibrary(m_hScitilla); 3 m_hScitilla = NULL; 4 }
1 hWndSci = CreateWindowEx( 0 , " Scintilla " , "" , 2 WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_CLIPCHILDREN, 3 10 , 10 , 500 , 400 ,hwndParent,(HMENU)GuiID, hInstance,NULL);
You can control the edit by sending commands.There are two ways to do that:A simple way and a fast way.
The simple ways is just like with any other windows.You can send messages to Scintilla Edit control and receive notifications from it ,note that the notification message is sent to its parent window.
For example,you can use SendMessage(hWndScintilla,SCI_CREATEDOCUMENT, 0, 0) to ask scintilla to create a new document.
Some of the commands will return a value and unused parameters should be set to NULL.
The fast way to control scintilla edit control is to call message handling functions by yourself.You can retrieve the pointer of the message handling
funciton of Scintilla and call it directly to execute a command.
You have to use SCI_GETDIRECTFUNCTION and SCI_GETDIRECTPOINTER commands to retrieve the pointer to the function and a pointer which
must be the first parameter when calling the retrieved function pointer.YOu have to do this with the SendMessage way.The whole things will be like this:
Code 1 int (*fn)(void*,int,int,int);2 void * ptr;3 int canundo;4 fn = (int (__cdecl *)(void *,int,int,int))5 SendMessage(hwndScintilla,SCI_GETDIRECTFUNCTION,0,0);6 ptr = (void *)SendMessage(hwndScintilla,SCI_GETDIRECTPOINTER,0,0);7 canundo = fn(ptr,SCI_CANUNDO,0,0
References:www.scitilla.org
Scintilla的windows版本是一个windows控件,所以其主要编程接口都是通过消息机制来实现的.早期的Scintilla版本模仿了标准的windows Edit和RichEdit控件定义的大部分API实现,然而现代这些API在Scintilla中都被摒弃,而改用Scintilla自己的API.
GTK版本使用了与windows版本类似的消息机制,这与一般的GTK设计方法不同但是更易于快速实现.