// Scintilla source code edit control // ScintillaBase.cxx - an enhanced subclass of Editor with calltips, autocomplete and context menu // Copyright 1998-2000 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #include #include #include #include #include "Platform.h" #include "Scintilla.h" #include "PropSet.h" #ifdef SCI_LEXER #include "SciLexer.h" #include "Accessor.h" #include "WindowAccessor.h" #include "DocumentAccessor.h" #include "KeyWords.h" #endif #include "ContractionState.h" #include "SVector.h" #include "CellBuffer.h" #include "CallTip.h" #include "KeyMap.h" #include "Indicator.h" #include "LineMarker.h" #include "Style.h" #include "ViewStyle.h" #include "AutoComplete.h" #include "Document.h" #include "Editor.h" #include "ScintillaBase.h" ScintillaBase::ScintillaBase() { #ifdef SCI_LEXER lexLanguage = SCLEX_CONTAINER; for (int wl=0;wlDeleteChars(currentPos, lenEntered); SetEmptySelection(currentPos); pdoc->InsertString(currentPos, list); SetEmptySelection(currentPos + strlen(list)); } else { SetEmptySelection(currentPos); pdoc->InsertString(currentPos, list + lenEntered); SetEmptySelection(currentPos + strlen(list + lenEntered)); } return; } } ac.Start(wDraw, idAutoComplete, currentPos, lenEntered); PRectangle rcClient = GetClientRectangle(); Point pt = LocationFromPosition(currentPos-lenEntered); int heightLB = 100; int widthLB = 100; if (pt.x >= rcClient.right - widthLB) { HorizontalScrollTo(xOffset + pt.x - rcClient.right + widthLB); Redraw(); pt = LocationFromPosition(currentPos); } PRectangle rcac; rcac.left = pt.x - 5; if (pt.y >= rcClient.bottom - heightLB && // Wont fit below. pt.y >= (rcClient.bottom + rcClient.top) / 2) { // and there is more room above. rcac.top = pt.y - heightLB; if (rcac.top < 0) { heightLB += rcac.top; rcac.top = 0; } } else { rcac.top = pt.y + vs.lineHeight; } rcac.right = rcac.left + widthLB; rcac.bottom = Platform::Minimum(rcac.top + heightLB, rcClient.bottom); ac.lb.SetPositionRelative(rcac, wMain); ac.lb.SetFont(vs.styles[STYLE_DEFAULT].font); ac.lb.SetAverageCharWidth(vs.styles[STYLE_DEFAULT].aveCharWidth); ac.SetList(list); // Fiddle the position of the list so it is right next to the target and wide enough for all its strings PRectangle rcList = ac.lb.GetDesiredRect(); int heightAlloced = rcList.bottom - rcList.top; widthLB = Platform::Maximum(widthLB, rcList.right - rcList.left); // Make an allowance for large strings in list rcList.left = pt.x - 5; rcList.right = rcList.left + widthLB; if (pt.y >= rcClient.bottom - heightLB && // Wont fit below. pt.y >= (rcClient.bottom + rcClient.top) / 2) { // and there is more room above. rcList.top = pt.y - heightAlloced; } else { rcList.top = pt.y + vs.lineHeight; } rcList.bottom = rcList.top + heightAlloced; ac.lb.SetPositionRelative(rcList, wMain); ac.Show(); if (lenEntered != 0) { AutoCompleteMoveToCurrentWord(); } } void ScintillaBase::AutoCompleteCancel() { ac.Cancel(); } void ScintillaBase::AutoCompleteMove(int delta) { ac.Move(delta); } void ScintillaBase::AutoCompleteMoveToCurrentWord() { char wordCurrent[1000]; int i; int startWord = ac.posStart - ac.startLen; for (i = startWord; i < currentPos; i++) wordCurrent[i - startWord] = pdoc->CharAt(i); wordCurrent[i - startWord] = '\0'; ac.Select(wordCurrent); } void ScintillaBase::AutoCompleteChanged(char ch) { if (ac.IsFillUpChar(ch)) { AutoCompleteCompleted(ch); } else if (currentPos <= ac.posStart - ac.startLen) { ac.Cancel(); } else if (ac.cancelAtStartPos && currentPos <= ac.posStart) { ac.Cancel(); } else if (ac.IsStopChar(ch)) { ac.Cancel(); } else { AutoCompleteMoveToCurrentWord(); } } void ScintillaBase::AutoCompleteCompleted(char fillUp/*='\0'*/) { int item = ac.lb.GetSelection(); char selected[1000]; if (item != -1) { ac.lb.GetValue(item, selected, sizeof(selected)); } ac.Cancel(); if (ac.ignoreCase) { if (currentPos != ac.posStart) { pdoc->DeleteChars(ac.posStart, currentPos - ac.posStart); } SetEmptySelection(ac.posStart - ac.startLen); pdoc->DeleteChars(ac.posStart - ac.startLen, ac.startLen); if (item != -1) { SString piece = selected; if (fillUp) piece += fillUp; pdoc->InsertString(currentPos, piece.c_str()); SetEmptySelection(currentPos + piece.length()); } } else { if (currentPos != ac.posStart) { pdoc->DeleteChars(ac.posStart, currentPos - ac.posStart); } SetEmptySelection(ac.posStart); if (item != -1) { SString piece = selected + ac.startLen; if (fillUp) piece += fillUp; pdoc->InsertString(currentPos, piece.c_str()); SetEmptySelection(currentPos + piece.length()); } } } void ScintillaBase::ContextMenu(Point pt) { popup.CreatePopUp(); AddToPopUp("Undo", idcmdUndo, pdoc->CanUndo()); AddToPopUp("Redo", idcmdRedo, pdoc->CanRedo()); AddToPopUp(""); AddToPopUp("Cut", idcmdCut, currentPos != anchor); AddToPopUp("Copy", idcmdCopy, currentPos != anchor); AddToPopUp("Paste", idcmdPaste, WndProc(SCI_CANPASTE, 0, 0)); AddToPopUp("Delete", idcmdDelete, currentPos != anchor); AddToPopUp(""); AddToPopUp("Select All", idcmdSelectAll); popup.Show(pt, wMain); } void ScintillaBase::CancelModes() { AutoCompleteCancel(); ct.CalHTTP/1.1 200 OK Connection: keep-alive Connection: keep-alive Content-Disposition: inline; filename="ScintillaBase.cxx" Content-Disposition: inline; filename="ScintillaBase.cxx" Content-Length: 12351 Content-Length: 12351 Content-Security-Policy: default-src 'none' Content-Security-Policy: default-src 'none' Content-Type: text/plain; charset=UTF-8 Content-Type: text/plain; charset=UTF-8 Date: Wed, 22 Oct 2025 11:33:00 UTC ETag: "4f182850ad452d6e37620458bf9529579e877541" ETag: "4f182850ad452d6e37620458bf9529579e877541" Expires: Sat, 20 Oct 2035 11:33:00 GMT Expires: Sat, 20 Oct 2035 11:33:00 GMT Last-Modified: Wed, 22 Oct 2025 11:33:00 GMT Last-Modified: Wed, 22 Oct 2025 11:33:00 GMT Server: OpenBSD httpd Server: OpenBSD httpd X-Content-Type-Options: nosniff X-Content-Type-Options: nosniff // Scintilla source code edit control // ScintillaBase.cxx - an enhanced subclass of Editor with calltips, autocomplete and context menu // Copyright 1998-2000 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #include #include #include #include #include "Platform.h" #include "Scintilla.h" #include "PropSet.h" #ifdef SCI_LEXER #include "SciLexer.h" #include "Accessor.h" #include "WindowAccessor.h" #include "DocumentAccessor.h" #include "KeyWords.h" #endif #include "ContractionState.h" #include "SVector.h" #include "CellBuffer.h" #include "CallTip.h" #include "KeyMap.h" #include "Indicator.h" #include "LineMarker.h" #include "Style.h" #include "ViewStyle.h" #include "AutoComplete.h" #include "Document.h" #include "Editor.h" #include "ScintillaBase.h" ScintillaBase::ScintillaBase() { #ifdef SCI_LEXER lexLanguage = SCLEX_CONTAINER; for (int wl=0;wl