From 221524e05b3e8566c0523b960ff9fdd55e1f2dc6 Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Fri, 25 Mar 2005 05:08:19 +0000 Subject: Patch from Blair McGlashan for autocompletion on Windows to * Set maximum width of list * set maximum height of list * better calculate width * use ellipsis when text is truncated to fit window * use popup window so it can extend past parent window * disallow resizing too small * draw to bottom edge when resized so last item not full line high * improve time to display by by 90% Minor tweaks by me to fix warnings, layout etc. --- doc/ScintillaDoc.html | 59 ++++++++++++++++++++++++++++++++++----------------- gtk/PlatGTK.cxx | 40 ++++++++++++++++++++++++++++++++-- 2 files changed, 78 insertions(+), 21 deletions(-) diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html index 879cccc36..3c23df0da 100644 --- a/doc/ScintillaDoc.html +++ b/doc/ScintillaDoc.html @@ -787,7 +787,7 @@ struct TextToFind { unless the document is read-only.

On X, the clipboard is asynchronous and may require several messages between - the destination and source applications. Data from SCI_PASTE will not arrive in the + the destination and source applications. Data from SCI_PASTE will not arrive in the document immediately.

SCI_COPYRANGE(int start, int end)
@@ -2323,8 +2323,8 @@ struct TextToFind { horizontal space, such as Thai, will mostly work but there are some issues where the characters are drawn separately leading to visual glitches. Bi-directional text is not supported.

-

On Windows, code page can be set to 932 (Japanese Shift-JIS), 936 (Simplified Chinese GBK), - 949 (Korean), and 950 (Traditional Chinese Big5) although these may require installation of language +

On Windows, code page can be set to 932 (Japanese Shift-JIS), 936 (Simplified Chinese GBK), + 949 (Korean), and 950 (Traditional Chinese Big5) although these may require installation of language specific support.

On GTK+, code page SC_CP_DBCS (1) sets Scintilla into @@ -2888,10 +2888,10 @@ struct TextToFind {

When the user makes a selection from the list the container is sent a SCN_AUTOCSELECTION notification message. On return from the notification Scintilla will insert + href="#Notifications">notification message. On return from the notification Scintilla will insert the selected text unless the autocompletion list has been cancelled, for example by the container sending SCI_AUTOCCANCEL.

- +

To make use of autocompletion you must monitor each character added to the document. See SciTEBase::CharAdded() in SciTEBase.cxx for an example of autocompletion.

SCI_AUTOCSHOW(int lenEntered, const char @@ -2928,6 +2928,10 @@ struct TextToFind { SCI_CLEARREGISTEREDIMAGES
SCI_AUTOCSETTYPESEPARATOR(char separatorCharacter)
SCI_AUTOCGETTYPESEPARATOR
+ SCI_AUTOCSETMAXHEIGHT(int rowCount)
+ SCI_AUTOCGETMAXHEIGHT
+ SCI_AUTOCSETMAXWIDTH(int characterCount)
+ SCI_AUTOCGETMAXWIDTH

SCI_AUTOCSHOW(int lenEntered, const char *list)
@@ -3037,6 +3041,23 @@ struct TextToFind { with SCI_AUTOCSETTYPESEPARATOR.

+

+ SCI_AUTOCSETMAXHEIGHT(int rowCount)
+ SCI_AUTOCGETMAXHEIGHT
+ + Get or set the maximum number of rows that will be visible in an autocompletion list. If there are more rows in the list, then a vertical + scrollbar is shown. The default is 5. +

+ +

+ SCI_AUTOCSETMAX(int characterCount)
+ SCI_AUTOCGETMAX
+ + Get or set the maximum width of an autocompletion list expressed as the number of characters in the longest item that will be totally visible. + If zero (the default) then the list's width is calculated to fit the item with the most characters. Any items that cannot be fully displayed within + the available width are indicated by the presence of ellipsis. +

+

User lists

User lists use the same internal mechanisms as autocompletion lists, and all the calls @@ -3599,10 +3620,10 @@ struct RangeToFormat { into the print rectangle. If you set SC_WRAP_NONE, each line of text generates one line of output and the line is truncated if it is too long to fit into the print area.
- SC_WRAP_WORD tries to wrap only between words as indicated by - white space or style changes although if a word is longer than a line, it will be wrapped before - the line end. SC_WRAP_CHAR is preferred to - SC_WRAP_WORD for Asian languages where there is no white space + SC_WRAP_WORD tries to wrap only between words as indicated by + white space or style changes although if a word is longer than a line, it will be wrapped before + the line end. SC_WRAP_CHAR is preferred to + SC_WRAP_WORD for Asian languages where there is no white space between words.

Direct access

@@ -3730,7 +3751,7 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){ The best way to see how this is done is to search the SciTE source code for the messages used in this section of the documentation and see how they are used. You will also need to use markers and a folding margin to complete your folding implementation. - The "fold" property should be set to "1" with + The "fold" property should be set to "1" with SCI_SETPROPERTY("fold", "1") to enable folding.

SCI_VISIBLEFROMDOCLINE(int docLine)
@@ -3945,13 +3966,13 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){

SCI_SETWRAPMODE(int wrapMode)
SCI_GETWRAPMODE
- Set wrapMode to SC_WRAP_WORD (1) to enable wrapping - on word boundaries, SC_WRAP_CHAR (2) to enable wrapping - between any characters, and to SC_WRAP_NONE (0) to disable line - wrapping. SC_WRAP_CHAR is preferred to - SC_WRAP_WORD for Asian languages where there is no white space + Set wrapMode to SC_WRAP_WORD (1) to enable wrapping + on word boundaries, SC_WRAP_CHAR (2) to enable wrapping + between any characters, and to SC_WRAP_NONE (0) to disable line + wrapping. SC_WRAP_CHAR is preferred to + SC_WRAP_WORD for Asian languages where there is no white space between words.

- +

SCI_SETWRAPVISUALFLAGS(int wrapVisualFlags)
SCI_GETWRAPVISUALFLAGS
@@ -4421,7 +4442,7 @@ href="#SCI_POSITIONFROMLINE">SCI_POSITIONFROMLINE(lineNumber); href="#SCI_SETREADONLY">SCI_SETREADONLY
.

SCN_KEY
- Reports all keys pressed but not consumed by Scintilla. Used on GTK+ because of + Reports all keys pressed but not consumed by Scintilla. Used on GTK+ because of some problems with keyboard focus and is not sent by the Windows version. SCNotification.ch holds the key code and SCNotification.modifiers holds the modifiers. This notification is sent if the modifiers include SCMOD_ALT or SCMOD_CTRL and the key code is less @@ -4490,7 +4511,7 @@ href="#SCI_POSITIONFROMLINE">SCI_POSITIONFROMLINE(lineNumber); Valid for text changes, not for style changes. If we are collecting undo information this holds a pointer to the text that is handed to the Undo system, otherwise - it is zero. For user performed SC_MOD_BEFOREDELETE the text field is 0 and + it is zero. For user performed SC_MOD_BEFOREDELETE the text field is 0 and for user performed SC_MOD_BEFOREINSERT the text field points to an array of cells, not bytes. @@ -4905,7 +4926,7 @@ for line = lineStart to lineEnd do SCI_ENSUREVISIBLE(line) next

SCN_AUTOCSELECTION
The user has selected an item in an autocompletion list. The - notification is sent before the selection is inserted. Automatic insertion can be cancelled by sending a + notification is sent before the selection is inserted. Automatic insertion can be cancelled by sending a SCI_AUTOCCANCEL message before returning from the notification. The SCNotification fields used are:

diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx index 00dc3d2a8..9ba18a8ce 100644 --- a/gtk/PlatGTK.cxx +++ b/gtk/PlatGTK.cxx @@ -1794,9 +1794,10 @@ public: } } virtual void SetFont(Font &font); - virtual void Create(Window &parent, int ctrlID, int lineHeight_, bool unicodeMode_); + virtual void Create(Window &parent, int ctrlID, Point location_, int lineHeight_, bool unicodeMode_); virtual void SetAverageCharWidth(int width); virtual void SetVisibleRows(int rows); + virtual int GetVisibleRows() const; virtual PRectangle GetDesiredRect(); virtual int CaretFromEdge(); virtual void Clear(); @@ -1812,6 +1813,7 @@ public: doubleClickAction = action; doubleClickActionData = data; } + virtual void SetList(const char* list, char separator, char typesep); }; ListBox *ListBox::Allocate() { @@ -1842,7 +1844,7 @@ static gboolean ButtonPress(GtkWidget *, GdkEventButton* ev, gpointer p) { return FALSE; } -void ListBoxX::Create(Window &, int, int, bool) { +void ListBoxX::Create(Window &, int, Point, int, bool) { id = gtk_window_new(GTK_WINDOW_POPUP); GtkWidget *frame = gtk_frame_new(NULL); @@ -1936,6 +1938,10 @@ void ListBoxX::SetVisibleRows(int rows) { desiredVisibleRows = rows; } +int ListBoxX::GetVisibleRows() const { + return desiredVisibleRows; +} + PRectangle ListBoxX::GetDesiredRect() { // Before any size allocated pretend its 100 wide so not scrolled PRectangle rc(0, 0, 100, 100); @@ -2280,6 +2286,36 @@ void ListBoxX::ClearRegisteredImages() { xset.Clear(); } +void ListBoxX::SetList(const char* list, char separator, char typesep) { + Clear(); + int count = strlen(list) + 1; + char *words = new char[count]; + if (words) { + memcpy(words, list, count); + char *startword = words; + char *numword = NULL; + int i = 0; + for (; words[i]; i++) { + if (words[i] == separator) { + words[i] = '\0'; + if (numword) + *numword = '\0'; + Append(startword, numword?atoi(numword + 1):-1); + startword = words + i + 1; + numword = NULL; + } else if (words[i] == typesep) { + numword = words + i; + } + } + if (startword) { + if (numword) + *numword = '\0'; + Append(startword, numword?atoi(numword + 1):-1); + } + delete []words; + } +} + Menu::Menu() : id(0) {} void Menu::CreatePopUp() { -- cgit v1.2.3