Skip to content

Commit

Permalink
Auto completion support all word characters other than [a-zA-Z0-9_], …
Browse files Browse the repository at this point in the history
…fix issue #36 and issue #73.
  • Loading branch information
zufuliu committed Jan 13, 2019
1 parent 05a1749 commit c4f533e
Show file tree
Hide file tree
Showing 11 changed files with 626 additions and 374 deletions.
2 changes: 2 additions & 0 deletions scintilla/include/Scintilla.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SCI_CLEARDOCUMENTSTYLE 2005
#define SCI_GETLENGTH 2006
#define SCI_GETCHARAT 2007
#define SCI_GETCHARACTERANDWIDTH 2038
#define SCI_ISAUTOCOMPLETIONWORDCHARACTER 2039
#define SCI_GETCURRENTPOS 2008
#define SCI_GETANCHOR 2009
#define SCI_GETSTYLEAT 2010
Expand Down
6 changes: 6 additions & 0 deletions scintilla/include/Scintilla.iface
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ get int GetLength=2006(,)
# Returns the character byte at the position.
get int GetCharAt=2007(position pos,)

# Returns the character at the position and.
get int GetCharacterAndWidth=2038(position pos, position width)

# Is character part of auto-completion word.
get bool IsAutoCompletionWordCharacter=2039(int ch,)

# Returns the position of the caret.
get position GetCurrentPos=2008(,)

Expand Down
4 changes: 4 additions & 0 deletions scintilla/src/Document.h
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,10 @@ class Document : PerLine, public IDocument, public ILoader {
}
Sci::Position BraceMatch(Sci::Position position, Sci::Position maxReStyle) noexcept;

bool IsAutoCompletionWordCharacter(unsigned int ch) const noexcept {
return WordCharacterClass(ch) == CharClassify::ccWord;
}

private:
void NotifyModifyAttempt() noexcept;
void NotifySavePoint(bool atSavePoint) noexcept;
Expand Down
6 changes: 6 additions & 0 deletions scintilla/src/Editor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -6269,6 +6269,12 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_GETCHARAT:
return static_cast<unsigned char>(pdoc->CharAt(wParam));

case SCI_GETCHARACTERANDWIDTH:
return pdoc->GetCharacterAndWidth(wParam, reinterpret_cast<Sci_Position *>(lParam));

case SCI_ISAUTOCOMPLETIONWORDCHARACTER:
return pdoc->IsAutoCompletionWordCharacter(static_cast<unsigned int>(wParam));

case SCI_SETCURRENTPOS:
if (sel.IsRectangular()) {
sel.Rectangular().caret.SetPosition(wParam);
Expand Down
2 changes: 2 additions & 0 deletions src/Edit.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,8 @@ typedef struct EditAutoCompletionConfig {

// in EditAutoC.c
void EditCompleteUpdateConfig(void);
BOOL IsDocWordChar(int ch);
BOOL IsAutoCompletionWordCharacter(int ch);
void EditCompleteWord(HWND hwnd, BOOL autoInsert);
void EditAutoCloseBraceQuote(HWND hwnd, int ch);
void EditAutoCloseXMLTag(HWND hwnd);
Expand Down

0 comments on commit c4f533e

Please sign in to comment.