Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Scintilla control modifies line text and Lexer
#7
I found two 32-bit dll files ver5.3.3 :  Lexilla.dll and Scintilla.dll (in the attachment below)

The following two commands cannot be executed with the following code
 
Code:
Copy      Help
SendMessage(sci SCI.SETLEXER SCLEX_CPP 0)
 
Code:
Copy      Help
,SendMessage(sci SCI.SETLEXER SCLEX_POWERSHELL 0)


Macro Macro5
 
Code:
Copy      Help
LoadLibraryW(@_s.expandpath("$desktop$\sci\Lexilla.dll"))
LoadLibraryW(@_s.expandpath("$desktop$\sci\Scintilla.dll"))

str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 384 240 "Dialog" "4"
;3 Scintilla 0x54000000 0x20000 8 8 368 206 ""
;4 Button 0x54032000 0x0 40 220 48 14 "C# Lexer"
;5 Button 0x54032000 0x0 104 220 48 14 "QM Lexer"
;6 Button 0x54032000 0x4 168 220 70 14 "Powershell  Lexer"
;1 Button 0x54030001 0x4 268 220 48 14 "OK"
;2 Button 0x54030000 0x4 328 220 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040C02 "*" "" "" ""

str controls="3"
str cs3
cs3=
;using System;
;namespace HelloWorld
;{
;,/// <summary>
;,/// Summary description for Class1.
;,/// </summary>
;,class HelloWorldClass
;,{
;,,static void Main(string[] args)
;,,{
;,,,Console.WriteLine("Hello World!");
;,,,Console.ReadLine();
;,,}
;,}
;}

str qm3.getmacro

str ps3=
;$Hash = @{ }
;$Hash = @{ a = 1; b = 2; c = 3 }
;$Hash.Add('d', 4)
;$Hash.ContainsKey('d')
;$Hash['d']
;$Hash.GetEnumerator() | Sort-Object Name

int sci

if(!ShowDialog(dd &sub.DlgProc 0)) ret


#sub DlgProc v
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,sci=id(3 hDlg)
,sub.SetText cs3
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,case 4 ;;C# Lexer
,sub.SetText cs3
,;SendMessage(sci SCI.SETLEXER SCLEX_CPP 0)
,
,case 5 ;;QM Lexer
,sub.SetText qm3
,
,case 6 ;;Powershell Lexer
,sub.SetText ps3
,;SendMessage(sci SCI.SETLEXER SCLEX_POWERSHELL 0)

ret 1

#sub Sci v
function# message [param1] [param2]
ret SendMessage(sci message param1 param2)

#sub Sci2 v
function# message [param1] [$text]
ret SendMessage(sci message param1 text)

#sub GetText v
function str&text
int n=SendMessage(sci SCI.SCI_GETTEXTLENGTH 0 0)
text.fix(SendMessage(sci SCI.SCI_GETTEXT n+1 text.all(n)))

#sub SetText v
function $text
sub.Sci2(SCI.SCI_SETTEXT 0 text)

I found the code for ScintillaNET. It's not very long
 
C# code:

namespace ScintillaNET.Demo {
public partial class MainForm : Form {
public MainForm() {
InitializeComponent();
}

ScintillaNET.Scintilla TextArea;

private void MainForm_Load(object sender, EventArgs e) {

// CREATE CONTROL
TextArea = new ScintillaNET.Scintilla();
TextPanel.Controls.Add(TextArea);

// BASIC CONFIG
TextArea.Dock = System.Windows.Forms.DockStyle.Fill;
TextArea.TextChanged += (this.OnTextChanged);

// INITIAL VIEW CONFIG
TextArea.WrapMode = WrapMode.None;
TextArea.IndentationGuides = IndentView.LookBoth;

// STYLING
InitColors();
InitSyntaxColoring();
}

private void InitColors() {

TextArea.SetSelectionBackColor(true, IntToColor(0x114D9C));

}

private void InitSyntaxColoring() {

// Configure the default style
TextArea.StyleResetDefault();
TextArea.Styles[Style.Default].Font = "Consolas";
TextArea.Styles[Style.Default].Size = 10;
TextArea.Styles[Style.Default].BackColor = IntToColor(0x212121);
TextArea.Styles[Style.Default].ForeColor = IntToColor(0xFFFFFF);
TextArea.StyleClearAll();

// Configure the CPP (C#) lexer styles
TextArea.Styles[Style.Cpp.Identifier].ForeColor = IntToColor(0xD0DAE2);
TextArea.Styles[Style.Cpp.Comment].ForeColor = IntToColor(0xBD758B);
TextArea.Styles[Style.Cpp.CommentLine].ForeColor = IntToColor(0x40BF57);
TextArea.Styles[Style.Cpp.CommentDoc].ForeColor = IntToColor(0x2FAE35);
TextArea.Styles[Style.Cpp.Number].ForeColor = IntToColor(0xFFFF00);
TextArea.Styles[Style.Cpp.String].ForeColor = IntToColor(0xFFFF00);
TextArea.Styles[Style.Cpp.Character].ForeColor = IntToColor(0xE95454);
TextArea.Styles[Style.Cpp.Preprocessor].ForeColor = IntToColor(0x8AAFEE);
TextArea.Styles[Style.Cpp.Operator].ForeColor = IntToColor(0xE0E0E0);
TextArea.Styles[Style.Cpp.Regex].ForeColor = IntToColor(0xff00ff);
TextArea.Styles[Style.Cpp.CommentLineDoc].ForeColor = IntToColor(0x77A7DB);
TextArea.Styles[Style.Cpp.Word].ForeColor = IntToColor(0x48A8EE);
TextArea.Styles[Style.Cpp.Word2].ForeColor = IntToColor(0xF98906);
TextArea.Styles[Style.Cpp.CommentDocKeyword].ForeColor = IntToColor(0xB3D991);
TextArea.Styles[Style.Cpp.CommentDocKeywordError].ForeColor = IntToColor(0xFF0000);
TextArea.Styles[Style.Cpp.GlobalClass].ForeColor = IntToColor(0x48A8EE);

TextArea.Lexer = Lexer.Cpp;

TextArea.SetKeywords(0, "class extends implements import interface new case do while else if for in switch throw get set function var try catch finally while with default break continue delete return each const namespace package include use is as instanceof typeof author copy default deprecated eventType example exampleText exception haxe inheritDoc internal link mtasc mxmlc param private return see serial serialData serialField since throws usage version langversion playerversion productversion dynamic private public partial static intrinsic internal native override protected AS3 final super this arguments null Infinity NaN undefined true false abstract as base bool break by byte case catch char checked class const continue decimal default delegate do double descending explicit event extern else enum false finally fixed float for foreach from goto group if implicit in int interface internal into is lock long new null namespace object operator out override orderby params private protected public readonly ref return switch struct sbyte sealed short sizeof stackalloc static string select this throw true try typeof uint ulong unchecked unsafe ushort using var virtual volatile void while where yield");
TextArea.SetKeywords(1, "void Null ArgumentError arguments Array Boolean Class Date DefinitionError Error EvalError Function int Math Namespace Number Object RangeError ReferenceError RegExp SecurityError String SyntaxError TypeError uint XML XMLList Boolean Byte Char DateTime Decimal Double Int16 Int32 Int64 IntPtr SByte Single UInt16 UInt32 UInt64 UIntPtr Void Path File System Windows Forms ScintillaNET");

}

private void OnTextChanged(object sender, EventArgs e) {

}

#region Numbers, Bookmarks, Code Folding

/// <summary>
/// the background color of the text area
/// </summary>
private const int BACK_COLOR = 0x2A211C;

/// <summary>
/// default text color of the text area
/// </summary>
private const int FORE_COLOR = 0xB7B7B7;

/// <summary>
/// change this to whatever margin you want the line numbers to show in
/// </summary>
private const int NUMBER_MARGIN = 1;

/// <summary>
/// change this to whatever margin you want the bookmarks/breakpoints to show in
/// </summary>
private const int BOOKMARK_MARGIN = 2;
private const int BOOKMARK_MARKER = 2;

/// <summary>
/// change this to whatever margin you want the code folding tree (+/-) to show in
/// </summary>
private const int FOLDING_MARGIN = 3;

/// <summary>
/// set this true to show circular buttons for code folding (the [+] and [-] buttons on the margin)
/// </summary>
private const bool CODEFOLDING_CIRCULAR = true;

private void TextArea_MarginClick(object sender, MarginClickEventArgs e) {
if (e.Margin == BOOKMARK_MARGIN) {
// Do we have a marker for this line?
const uint mask = (1 << BOOKMARK_MARKER);
var line = TextArea.Lines[TextArea.LineFromPosition(e.Position)];
if ((line.MarkerGet() & mask) > 0) {
// Remove existing bookmark
line.MarkerDelete(BOOKMARK_MARKER);
} else {
// Add bookmark
line.MarkerAdd(BOOKMARK_MARKER);
}
}
}
#endregion
}
}



Attached Files
.zip   Scintilla_Lexilla.zip (Size: 903.95 KB / Downloads: 79)


Messages In This Thread
RE: Scintilla control modifies line text and Lexer - by Davider - 02-17-2023, 12:06 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)