/// <summary> /// Given a document position which is filled with this indicator, will return the document position /// where the use of this indicator ends. /// </summary> /// <param name="position">A zero-based document position using this indicator.</param> /// <returns>The zero-based document position where the use of this indicator ends.</returns> /// <remarks> /// Specifying a <paramref name="position" /> which is not filled with this indicator will cause this method /// to return the end position of the range where this indicator is not in use (the negative space). If this /// indicator is not in use anywhere within the document the return value will be 0. /// </remarks> public int End(int position) { position = Helpers.Clamp(position, 0, scintilla.TextLength); position = scintilla.Lines.CharToBytePosition(position); position = scintilla.DirectMessage(NativeMethods.SCI_INDICATOREND, new IntPtr(Index), new IntPtr(position)).ToInt32(); return(scintilla.Lines.ByteToCharPosition(position)); }
public LineStorageData GetData(int lineIndex) { Debug.Assert(lineIndex >= 0); Debug.Assert(lineIndex < (int)_scintilla.DirectMessage(NativeMethods.SCI_GETLINECOUNT, IntPtr.Zero, IntPtr.Zero)); return(_lineData[lineIndex]); }
public virtual void MoveFormAwayFromSelection() { if (!Visible || _scintilla == null) { return; } if (!AutoPosition) { return; } int pos = _scintilla.CurrentPosition; int x = _scintilla.PointXFromPosition(pos); int y = _scintilla.PointYFromPosition(pos); Point cursorPoint = new Point(x, y); Rectangle r = new Rectangle(Location, Size); if (_scintilla != null) { r.Location = new Point(_scintilla.ClientRectangle.Right - Size.Width, 0); } if (r.Contains(cursorPoint)) { Point newLocation; if (cursorPoint.Y < (Screen.PrimaryScreen.Bounds.Height / 2)) { //TODO - replace lineheight with ScintillaNET command, when added int SCI_TEXTHEIGHT = 2279; int lineHeight = _scintilla.DirectMessage(SCI_TEXTHEIGHT, IntPtr.Zero, IntPtr.Zero).ToInt32(); // Top half of the screen newLocation = new Point(r.X, cursorPoint.Y + lineHeight * 2); } else { //TODO - replace lineheight with ScintillaNET command, when added int SCI_TEXTHEIGHT = 2279; int lineHeight = _scintilla.DirectMessage(SCI_TEXTHEIGHT, IntPtr.Zero, IntPtr.Zero).ToInt32(); // Bottom half of the screen newLocation = new Point(r.X, cursorPoint.Y - Height - (lineHeight * 2)); } Location = newLocation; } else { Location = r.Location; } }
private void InvalidateCache(int lineIndex, int linesAdded) { Debug.Assert(lineIndex >= 0); Debug.Assert(lineIndex < (int)_scintilla.DirectMessage(NativeMethods.SCI_GETLINECOUNT, IntPtr.Zero, IntPtr.Zero)); // Invalidate the cached length for the modified line and any lines added int endLineIndex = lineIndex + linesAdded + 1; while (lineIndex < endLineIndex) { SetCachedLength(lineIndex, UNCACHED); lineIndex++; } }
public virtual void MoveFormAwayFromSelection() { if (!Visible) { return; } if (!AutoPosition) { return; } int pos = Scintilla.CurrentPosition; int x = Scintilla.PointXFromPosition(pos); int y = Scintilla.PointYFromPosition(pos); Point cursorPoint = Scintilla.PointToScreen(new Point(x, y)); Rectangle r = new Rectangle(Location, Size); if (r.Contains(cursorPoint)) { Point newLocation; if (cursorPoint.Y < (Screen.PrimaryScreen.Bounds.Height / 2)) { //TODO - replace lineheight with ScintillaNET command, when added int SCI_TEXTHEIGHT = 2279; int lineHeight = Scintilla.DirectMessage(SCI_TEXTHEIGHT, IntPtr.Zero, IntPtr.Zero).ToInt32(); // int lineHeight = Scintilla.Lines[Scintilla.LineFromPosition(pos)].Height; // Top half of the screen newLocation = Scintilla.PointToClient( new Point(Location.X, cursorPoint.Y + lineHeight * 2)); } else { //TODO - replace lineheight with ScintillaNET command, when added int SCI_TEXTHEIGHT = 2279; int lineHeight = Scintilla.DirectMessage(SCI_TEXTHEIGHT, IntPtr.Zero, IntPtr.Zero).ToInt32(); // int lineHeight = Scintilla.Lines[Scintilla.LineFromPosition(pos)].Height; // Bottom half of the screen newLocation = Scintilla.PointToClient( new Point(Location.X, cursorPoint.Y - Height - (lineHeight * 2))); } newLocation = Scintilla.PointToScreen(newLocation); Location = newLocation; } }
public virtual void ForceMoveFormAwayFromSelection() { int pos = Scintilla.CurrentPosition; int x = Scintilla.PointXFromPosition(pos); int y = Scintilla.PointYFromPosition(pos); Point scintillaCursorPoint = Scintilla.PointToScreen(new Point(x, y)); Screen scintillaCurrentScreen = Screen.FromPoint(scintillaCursorPoint); Screen findReplaceDialogCurrentScreen = Screen.FromPoint(Location); bool sameScreen = scintillaCurrentScreen.Equals(findReplaceDialogCurrentScreen); if (!sameScreen) { // Move FindReplaceDialog window to the same screen. Location = scintillaCursorPoint; } Rectangle findReplaceDialogCurrentRectangle = new Rectangle(Location, Size); Point newLocation; if (scintillaCursorPoint.Y < (scintillaCurrentScreen.Bounds.Height / 2)) { //TODO - replace lineheight with ScintillaNET command, when added int SCI_TEXTHEIGHT = 2279; int lineHeight = Scintilla.DirectMessage(SCI_TEXTHEIGHT, IntPtr.Zero, IntPtr.Zero).ToInt32(); // int lineHeight = Scintilla.Lines[Scintilla.LineFromPosition(pos)].Height; // Top half of the screen newLocation = Scintilla.PointToClient( new Point(scintillaCursorPoint.X, scintillaCursorPoint.Y + lineHeight * 2)); } else { //TODO - replace lineheight with ScintillaNET command, when added int SCI_TEXTHEIGHT = 2279; int lineHeight = Scintilla.DirectMessage(SCI_TEXTHEIGHT, IntPtr.Zero, IntPtr.Zero).ToInt32(); // int lineHeight = Scintilla.Lines[Scintilla.LineFromPosition(pos)].Height; // Bottom half of the screen newLocation = Scintilla.PointToClient( new Point(scintillaCursorPoint.X, scintillaCursorPoint.Y - Height - (lineHeight * 2))); } newLocation = Scintilla.PointToScreen(newLocation); Location = newLocation; }
/// <summary> /// Sets the marker symbol to a custom image. /// </summary> /// <param name="image">The Bitmap to use as a marker symbol.</param> /// <remarks>Calling this method will also update the <see cref="Symbol" /> property to <see cref="MarkerSymbol.RgbaImage" />.</remarks> public unsafe void DefineRgbaImage(Bitmap image) { if (image == null) { return; } scintilla.DirectMessage(NativeMethods.SCI_RGBAIMAGESETWIDTH, new IntPtr(image.Width)); scintilla.DirectMessage(NativeMethods.SCI_RGBAIMAGESETHEIGHT, new IntPtr(image.Height)); var bytes = Helpers.BitmapToArgb(image); fixed(byte *bp = bytes) scintilla.DirectMessage(NativeMethods.SCI_MARKERDEFINERGBAIMAGE, new IntPtr(Index), new IntPtr(bp)); }
/// <summary> /// Gets the cursor of this <see cref="Scintilla"/> control. /// </summary> /// <param name="scintilla">The scintilla.</param> /// <returns>The current cursor with this <see cref="Scintilla"/> control.</returns> public static Cursor GetCursor(this Scintilla scintilla) { try { var result = scintilla.DirectMessage(SCI_GETCURSOR, (IntPtr)0, (IntPtr)0); var value = result.ToInt32(); if (value == -1) { value = 0; } var cursor = ScintillaCursorMapping.FirstOrDefault(f => f.Key == value); // Debug.Print(cursor.ToString()); return(cursor.Value); } catch { return(Cursors.Default); } }
/// <summary> /// Sets the cursor of this <see cref="Scintilla"/> control. /// </summary> /// <param name="scintilla">The scintilla.</param> /// <param name="cursor">The cursor to set for this <see cref="Scintilla"/> control.</param> /// <returns><c>true</c> if the operation was successful, <c>false</c> otherwise.</returns> public static bool SetCursor(this Scintilla scintilla, Cursor cursor) { try { var currentCursor = scintilla.GetCursor(); if (cursor == currentCursor) { //Debug.Print("No change in cursors.."); return(false); } // Debug.Print(cursor + " / " + currentCursor); var cursorValue = ScintillaCursorMapping.First(f => f.Value == cursor).Key; scintilla.DirectMessage(SCI_SETCURSOR, (IntPtr)cursorValue, (IntPtr)0); return(true); } catch { return(false); } }
public static int zGetLineIndent(this Scintilla scintilla, int line) { return(scintilla.DirectMessage(SCI_GETLINEINDENTATION, new IntPtr(line), IntPtr.Zero).ToInt32()); }
private int GetIndent(Scintilla scin, int line) { return(scin.DirectMessage(SCI_GETLINEINDENTATION, new IntPtr(line), (IntPtr)null).ToInt32()); }
private void SetIndent(Scintilla scin, int line, int indent) { scin.DirectMessage(SCI_SETLINEINDENTATION, new IntPtr(line), new IntPtr(indent)); }
private void InitSyntaxColoring() { Color foreColor = IntToColor(MainWindow.FORE_COLOR); Color backColor = IntToColor(MainWindow.BACK_COLOR); if (theme == 1) { foreColor = IntToColor(MainWindow.BACK_COLOR); backColor = IntToColor(MainWindow.FORE_COLOR); } // Configure the default style textArea.StyleResetDefault(); //textArea.Styles[Style.CallTip].Font = "Consolas"; //textArea.Styles[Style.CallTip].Size = 20; textArea.Styles[Style.Default].Font = "Consolas"; textArea.Styles[Style.Default].Size = 10; textArea.Styles[Style.Default].BackColor = backColor; textArea.Styles[Style.Default].ForeColor = foreColor; textArea.CaretForeColor = foreColor; textArea.TabWidth = MainWindow.indentSpaces; spaces = ""; for (int i = 0; i < textArea.TabWidth; i++) { spaces += " "; } textArea.StyleClearAll(); textArea.Styles[Style.LineNumber].ForeColor = IntToColor(MainWindow.FORE_MARGIN_COLOR); textArea.Styles[Style.LineNumber].BackColor = IntToColor(MainWindow.BACK_MARGIN_COLOR); textArea.Styles[Style.IndentGuide].ForeColor = IntToColor(MainWindow.FORE_FOLDING_COLOR); textArea.Styles[Style.IndentGuide].BackColor = IntToColor(MainWindow.BACK_FOLDING_COLOR); textArea.Styles[STYLE_SPACE].ForeColor = foreColor; textArea.Styles[STYLE_COMMENT].ForeColor = IntToColor(MainWindow.COMMENT_COLOR); textArea.Styles[STYLE_STRING].ForeColor = IntToColor(MainWindow.STRING_COLOR); textArea.Styles[STYLE_OPERATOR].ForeColor = IntToColor(MainWindow.OPERATOR_COLOR); textArea.Styles[STYLE_KEYWORD].ForeColor = IntToColor(MainWindow.KEYWORD_COLOR); textArea.Styles[STYLE_OBJECT].ForeColor = IntToColor(MainWindow.OBJECT_COLOR); textArea.Styles[STYLE_METHOD].ForeColor = IntToColor(MainWindow.METHOD_COLOR); textArea.Styles[STYLE_SUBROUTINE].ForeColor = foreColor; textArea.Styles[STYLE_LABEL].ForeColor = foreColor; textArea.Styles[STYLE_VARIABLE].ForeColor = foreColor; textArea.Styles[STYLE_LITERAL].ForeColor = IntToColor(MainWindow.LITERAL_COLOR); textArea.Styles[STYLE_COMMENT].Italic = true; textArea.Styles[STYLE_KEYWORD].Bold = true; styles.Add(new SBStyle(STYLE_COMMENT, new Regex("^[\'].*"))); styles.Add(new SBStyle(STYLE_STRING, new Regex("^[\"][^\"\\n]*[\"\\n]"))); styles.Add(new SBStyle(STYLE_OPERATOR, new Regex("^[\\+|\\-|*|/|<|>|=]|^( AND | OR )"))); styles.Add(new SBStyle(STYLE_SPACE, new Regex("^[\\s]"))); styles.Add(new SBStyle(STYLE_KEYWORD, new Regex("^[\\W](" + keywords.ToUpper() + ")[\\W]"))); styles.Add(new SBStyle(STYLE_OBJECT, new Regex("^[A-Za-z_][\\w]*[\\.][A-Za-z_][\\w]*"))); styles.Add(new SBStyle(STYLE_SUBROUTINE, new Regex("^[A-Za-z_][\\w]*[(]"))); styles.Add(new SBStyle(STYLE_LABEL, new Regex("^[A-Za-z_][\\w]*[ ]*[:]"))); styles.Add(new SBStyle(STYLE_VARIABLE, new Regex("^[A-Za-z_][\\w]*[\\W]"))); styles.Add(new SBStyle(STYLE_LITERAL, new Regex("^[-?\\d*\\.?\\d*]"))); // Configure the lexer styles textArea.Lexer = Lexer.Container; const int SCI_CALLTIPSETBACK = 2205; const int SCI_CALLTIPSETFORE = 2206; textArea.DirectMessage(SCI_CALLTIPSETBACK, new IntPtr(ColorTranslator.ToWin32(SBDocument.IntToColor(MainWindow.BACK_CALLTIP_COLOR))), IntPtr.Zero); textArea.DirectMessage(SCI_CALLTIPSETFORE, new IntPtr(ColorTranslator.ToWin32(SBDocument.IntToColor(MainWindow.FORE_CALLTIP_COLOR))), IntPtr.Zero); textArea.CallTipSetForeHlt(SBDocument.IntToColor(MainWindow.HIGHLIGHT_CALLTIP_COLOR)); }
public static void zSetLineIndent(this Scintilla scintilla, int line, int indent) { scintilla.DirectMessage(SCI_SETLINEINDENTATION, new IntPtr(line), new IntPtr(indent)); }
int GetIndent(Scintilla scintilla, int line) { return(scintilla.DirectMessage(SCI_GETLINEINDENTATION, new IntPtr(line), IntPtr.Zero).ToInt32()); }
public static unsafe int DirectMessage(this Scintilla control, int msg, int wParam, string lParam) { fixed(byte *bp = Encoding.UTF8.GetBytes(ZeroTerminated(lParam))) return((int)control.DirectMessage(msg, (IntPtr)wParam, (IntPtr)bp)); }
/// <summary> /// Gets the caret position at the end of indentation on the specified line /// </summary> public static int GetLineIndentationPosition(this Scintilla control, int line) { return(control.Lines.ByteToCharPosition( (int)control.DirectMessage(SCI_GETLINEINDENTPOSITION, (IntPtr)line, (IntPtr)0))); }
/// <summary> /// Removes all text displayed in every <see cref="MarginType.Text" /> and <see cref="MarginType.RightText" /> margins. /// </summary> public void ClearAllText() { scintilla.DirectMessage(NativeMethods.SCI_MARGINTEXTCLEARALL); }
private void SetPrintMagnification(int magnification) { m_oScintillaControl.DirectMessage(SCI_SETPRINTMAGNIFICATION, new IntPtr(magnification), IntPtr.Zero); }
/// <summary> /// Expands any parent folds to ensure the line is visible. /// </summary> public void EnsureVisible() { scintilla.DirectMessage(NativeMethods.SCI_ENSUREVISIBLE, new IntPtr(Index)); }