Skip to content

Commit

Permalink
feat: [editor] Improved code completion
Browse files Browse the repository at this point in the history
as title

Log: Improved code completion
  • Loading branch information
Kakueeen committed Sep 18, 2024
1 parent a3c5401 commit f168bbc
Show file tree
Hide file tree
Showing 27 changed files with 622 additions and 30 deletions.
25 changes: 25 additions & 0 deletions 3rdparty/unioncode-qscintilla214/scintilla/include/Platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,25 @@ class PRectangle {
right += xDelta;
bottom += yDelta;
}
Point Centre() const noexcept {
return Point((left + right) / 2, (top + bottom) / 2);
}

XYPOSITION Width() const noexcept { return right - left; }
XYPOSITION Height() const noexcept { return bottom - top; }
bool Empty() const noexcept {
return (Height() <= 0) || (Width() <= 0);
}
};

XYPOSITION PixelAlign(XYPOSITION xy, int pixelDivisions) noexcept;
XYPOSITION PixelAlignFloor(XYPOSITION xy, int pixelDivisions) noexcept;
XYPOSITION PixelAlignCeil(XYPOSITION xy, int pixelDivisions) noexcept;

Point PixelAlign(const Point &pt, int pixelDivisions) noexcept;

PRectangle PixelAlign(const PRectangle &rc, int pixelDivisions) noexcept;

/**
* Holds an RGB colour with 8 bits for each component.
*/
Expand Down Expand Up @@ -350,6 +362,14 @@ class Surface {
virtual void Init(SurfaceID sid, WindowID wid)=0;
virtual void InitPixMap(int width, int height, Surface *surface_, WindowID wid)=0;

enum class Ends {
semiCircles = 0x0,
leftFlat = 0x1,
leftAngle = 0x2,
rightFlat = 0x10,
rightAngle = 0x20,
};

virtual void Release()=0;
virtual bool Initialised()=0;
virtual void PenColour(ColourDesired fore)=0;
Expand All @@ -360,6 +380,7 @@ class Surface {
virtual void Polygon(Point *pts, size_t npts, ColourDesired fore, ColourDesired back)=0;
virtual void RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back)=0;
virtual void FillRectangle(PRectangle rc, ColourDesired back)=0;
virtual void RectangleFrame(PRectangle rc, ColourDesired fore) = 0;
virtual void FillRectangle(PRectangle rc, Surface &surfacePattern)=0;
virtual void RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesired back)=0;
virtual void AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fill, int alphaFill,
Expand All @@ -368,13 +389,17 @@ class Surface {
virtual void GradientRectangle(PRectangle rc, const std::vector<ColourStop> &stops, GradientOptions options)=0;
virtual void DrawRGBAImage(PRectangle rc, int width, int height, const unsigned char *pixelsImage) = 0;
virtual void Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back)=0;
virtual void Stadium(PRectangle rc, ColourDesired fore, ColourDesired back, Ends ends) = 0;
virtual void Copy(PRectangle rc, Point from, Surface &surfaceSource)=0;

virtual void DrawTextNoClip(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore, ColourDesired back)=0;
virtual void DrawTextClipped(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore, ColourDesired back)=0;
virtual void DrawTextTransparent(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore)=0;
virtual void MeasureWidths(Font &font_, const char *s, int len, XYPOSITION *positions)=0;
virtual XYPOSITION WidthText(Font &font_, const char *s, int len)=0;

virtual XYPOSITION WidthTextUTF8(Font &font_, const char *s) = 0;

virtual XYPOSITION Ascent(Font &font_)=0;
virtual XYPOSITION Descent(Font &font_)=0;
virtual XYPOSITION InternalLeading(Font &font_)=0;
Expand Down
24 changes: 24 additions & 0 deletions 3rdparty/unioncode-qscintilla214/scintilla/include/Scintilla.h
Original file line number Diff line number Diff line change
Expand Up @@ -885,6 +885,29 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SCI_ANNOTATIONGETVISIBLE 2549
#define SCI_ANNOTATIONSETSTYLEOFFSET 2550
#define SCI_ANNOTATIONGETSTYLEOFFSET 2551

#define SCI_EOLANNOTATIONSETTEXT 2740
#define SCI_EOLANNOTATIONGETTEXT 2741
#define SCI_EOLANNOTATIONSETSTYLE 2742
#define SCI_EOLANNOTATIONGETSTYLE 2743
#define SCI_EOLANNOTATIONCLEARALL 2744
#define EOLANNOTATION_HIDDEN 0x0
#define EOLANNOTATION_STANDARD 0x1
#define EOLANNOTATION_BOXED 0x2
#define EOLANNOTATION_STADIUM 0x100
#define EOLANNOTATION_FLAT_CIRCLE 0x101
#define EOLANNOTATION_ANGLE_CIRCLE 0x102
#define EOLANNOTATION_CIRCLE_FLAT 0x110
#define EOLANNOTATION_FLATS 0x111
#define EOLANNOTATION_ANGLE_FLAT 0x112
#define EOLANNOTATION_CIRCLE_ANGLE 0x120
#define EOLANNOTATION_FLAT_ANGLE 0x121
#define EOLANNOTATION_ANGLES 0x122
#define SCI_EOLANNOTATIONSETVISIBLE 2745
#define SCI_EOLANNOTATIONGETVISIBLE 2746
#define SCI_EOLANNOTATIONSETSTYLEOFFSET 2747
#define SCI_EOLANNOTATIONGETSTYLEOFFSET 2748

#define SCI_RELEASEALLEXTENDEDSTYLES 2552
#define SCI_ALLOCATEEXTENDEDSTYLES 2553
#define UNDO_MAY_COALESCE 1
Expand Down Expand Up @@ -1041,6 +1064,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SC_MOD_LEXERSTATE 0x80000
#define SC_MOD_INSERTCHECK 0x100000
#define SC_MOD_CHANGETABSTOPS 0x200000
#define SC_MOD_CHANGEEOLANNOTATION 0x400000
#define SC_MODEVENTMASKALL 0x3FFFFF
#define SC_UPDATE_CONTENT 0x1
#define SC_UPDATE_SELECTION 0x2
Expand Down
53 changes: 50 additions & 3 deletions 3rdparty/unioncode-qscintilla214/scintilla/src/Document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ Document::Document(int options) :
perLineData[ldState].reset(new LineState());
perLineData[ldMargin].reset(new LineAnnotation());
perLineData[ldAnnotation].reset(new LineAnnotation());
perLineData[ldEOLAnnotation].reset(new LineAnnotation());

decorations = DecorationListCreate(IsLarge());

Expand Down Expand Up @@ -205,7 +206,12 @@ LineAnnotation *Document::Margins() const {
}

LineAnnotation *Document::Annotations() const {
return static_cast<LineAnnotation *>(perLineData[ldAnnotation].get());
return static_cast<LineAnnotation *>(perLineData[ldAnnotation].get());
}

LineAnnotation *Document::EOLAnnotations() const
{
return static_cast<LineAnnotation *>(perLineData[ldEOLAnnotation].get());
}

int Document::LineEndTypesSupported() const {
Expand Down Expand Up @@ -1483,7 +1489,6 @@ Sci::Position Document::SetLineIndentation(Sci::Line line, Sci::Position indent)
std::string linebuf = CreateIndentation(indent, tabInChars, !useTabs);
const Sci::Position thisLineStart = LineStart(line);
const Sci::Position indentPos = GetLineIndentPosition(line);
UndoGroup ug(this);
DeleteChars(thisLineStart, indentPos - thisLineStart);
return thisLineStart + InsertString(thisLineStart, linebuf.c_str(),
linebuf.length());
Expand Down Expand Up @@ -2351,11 +2356,53 @@ int Document::AnnotationLines(Sci::Line line) const {
}

void Document::AnnotationClearAll() {
if (Annotations()->Empty()) {
return;
}
const Sci::Line maxEditorLine = LinesTotal();
for (Sci::Line l=0; l<maxEditorLine; l++)
AnnotationSetText(l, nullptr);
// Free remaining data
Annotations()->ClearAll();
Annotations()->ClearAll();
}

StyledText Document::EOLAnnotationStyledText(Sci::Line line) const
{
const LineAnnotation *pla = EOLAnnotations();
return StyledText(pla->Length(line), pla->Text(line),
pla->MultipleStyles(line), pla->Style(line), pla->Styles(line));
}

void Document::EOLAnnotationSetStyle(Sci::Line line, int style)
{
if (line >= 0 && line < LinesTotal()) {
EOLAnnotations()->SetStyle(line, style);
const DocModification mh(SC_MOD_CHANGEEOLANNOTATION, LineStart(line),
0, 0, nullptr, line);
NotifyModified(mh);
}
}

void Document::EOLAnnotationSetText(Sci::Line line, const char *text)
{
if (line >= 0 && line < LinesTotal()) {
EOLAnnotations()->SetText(line, text);
const DocModification mh(SC_MOD_CHANGEEOLANNOTATION, LineStart(line),
0, 0, nullptr, line);
NotifyModified(mh);
}
}

void Document::EOLAnnotationClearAll()
{
if (EOLAnnotations()->Empty()) {
return;
}
const Sci::Line maxEditorLine = LinesTotal();
for (Sci::Line l=0; l<maxEditorLine; l++)
EOLAnnotationSetText(l, nullptr);
// Free remaining data
EOLAnnotations()->ClearAll();
}

void Document::IncrementStyleClock() noexcept {
Expand Down
8 changes: 7 additions & 1 deletion 3rdparty/unioncode-qscintilla214/scintilla/src/Document.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,14 @@ class Document : PerLine, public IDocumentWithLineEnd, public ILoader {
std::vector<WatcherWithUserData> watchers;

// ldSize is not real data - it is for dimensions and loops
enum lineData { ldMarkers, ldLevels, ldState, ldMargin, ldAnnotation, ldSize };
enum lineData { ldMarkers, ldLevels, ldState, ldMargin, ldAnnotation, ldEOLAnnotation, ldSize };
std::unique_ptr<PerLine> perLineData[ldSize];
LineMarkers *Markers() const;
LineLevels *Levels() const;
LineState *States() const;
LineAnnotation *Margins() const;
LineAnnotation *Annotations() const;
LineAnnotation *EOLAnnotations() const;

bool matchesValid;
std::unique_ptr<RegexSearchBase> regex;
Expand Down Expand Up @@ -476,6 +477,11 @@ class Document : PerLine, public IDocumentWithLineEnd, public ILoader {
int AnnotationLines(Sci::Line line) const;
void AnnotationClearAll();

StyledText EOLAnnotationStyledText(Sci::Line line) const;
void EOLAnnotationSetStyle(Sci::Line line, int style);
void EOLAnnotationSetText(Sci::Line line, const char *text);
void EOLAnnotationClearAll();

bool AddWatcher(DocWatcher *watcher, void *userData);
bool RemoveWatcher(DocWatcher *watcher, void *userData);

Expand Down
Loading

0 comments on commit f168bbc

Please sign in to comment.