本文整理汇总了C#中ScintillaNet.ScintillaControl.Colourise方法的典型用法代码示例。如果您正苦于以下问题:C# ScintillaControl.Colourise方法的具体用法?C# ScintillaControl.Colourise怎么用?C# ScintillaControl.Colourise使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ScintillaNet.ScintillaControl
的用法示例。
在下文中一共展示了ScintillaControl.Colourise方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateExtractVariable
public static void GenerateExtractVariable(ScintillaControl Sci, string NewName)
{
FileModel cFile;
string expression = Sci.SelText.Trim(new char[] { '=', ' ', '\t', '\n', '\r', ';', '.' });
expression = expression.TrimEnd(new char[] { '(', '[', '{', '<' });
expression = expression.TrimStart(new char[] { ')', ']', '}', '>' });
cFile = ASContext.Context.CurrentModel;
ASFileParser parser = new ASFileParser();
parser.ParseSrc(cFile, Sci.Text);
MemberModel current = cFile.Context.CurrentMember;
string characterClass = ScintillaControl.Configuration.GetLanguage(Sci.ConfigurationLanguage).characterclass.Characters;
int funcBodyStart = GetBodyStart(current.LineFrom, current.LineTo, Sci);
Sci.SetSel(funcBodyStart, Sci.LineEndPosition(current.LineTo));
string currentMethodBody = Sci.SelText;
bool isExprInSingleQuotes = (expression.StartsWith('\'') && expression.EndsWith('\''));
bool isExprInDoubleQuotes = (expression.StartsWith('\"') && expression.EndsWith('\"'));
int stylemask = (1 << Sci.StyleBits) - 1;
int lastPos = -1;
char prevOrNextChar;
Sci.Colourise(0, -1);
while (true)
{
lastPos = currentMethodBody.IndexOfOrdinal(expression, lastPos + 1);
if (lastPos > -1)
{
if (lastPos > 0)
{
prevOrNextChar = currentMethodBody[lastPos - 1];
if (characterClass.IndexOf(prevOrNextChar) > -1)
{
continue;
}
}
if (lastPos + expression.Length < currentMethodBody.Length)
{
prevOrNextChar = currentMethodBody[lastPos + expression.Length];
if (characterClass.IndexOf(prevOrNextChar) > -1)
{
continue;
}
}
int style = Sci.StyleAt(funcBodyStart + lastPos) & stylemask;
if (ASComplete.IsCommentStyle(style))
{
continue;
}
else if ((isExprInDoubleQuotes && currentMethodBody[lastPos] == '"' && currentMethodBody[lastPos + expression.Length - 1] == '"')
|| (isExprInSingleQuotes && currentMethodBody[lastPos] == '\'' && currentMethodBody[lastPos + expression.Length - 1] == '\''))
{
}
else if (!ASComplete.IsTextStyle(style))
{
continue;
}
Sci.SetSel(funcBodyStart + lastPos, funcBodyStart + lastPos + expression.Length);
Sci.ReplaceSel(NewName);
currentMethodBody = currentMethodBody.Substring(0, lastPos) + NewName + currentMethodBody.Substring(lastPos + expression.Length);
lastPos += NewName.Length;
}
else
{
break;
}
}
Sci.CurrentPos = funcBodyStart;
Sci.SetSel(Sci.CurrentPos, Sci.CurrentPos);
MemberModel m = new MemberModel(NewName, "", FlagType.LocalVar, 0);
m.Value = expression;
string snippet = TemplateUtils.GetTemplate("Variable");
snippet = TemplateUtils.ReplaceTemplateVariable(snippet, "Modifiers", null);
snippet = TemplateUtils.ToDeclarationString(m, snippet);
snippet += NewLine + "$(Boundary)";
SnippetHelper.InsertSnippetText(Sci, Sci.CurrentPos, snippet);
}
示例2: OnUpdateCallTip
private void OnUpdateCallTip(ScintillaControl sci, int position)
{
if (ASComplete.HasCalltip())
{
int pos = sci.CurrentPos - 1;
char c = (char)sci.CharAt(pos);
if ((c == ',' || c == '(') && sci.BaseStyleAt(pos) == 0)
sci.Colourise(0, -1);
ASComplete.HandleFunctionCompletion(sci, false, true);
}
}
示例3: ApplySciSettings
/// <summary>
/// Updates editor Globals.Settings to the specified ScintillaControl
/// </summary>
public static void ApplySciSettings(ScintillaControl sci)
{
try
{
sci.CaretPeriod = Globals.Settings.CaretPeriod;
sci.CaretWidth = Globals.Settings.CaretWidth;
sci.EOLMode = LineEndDetector.DetectNewLineMarker(sci.Text, (Int32)Globals.Settings.EOLMode);
sci.IsBraceMatching = Globals.Settings.BraceMatchingEnabled;
sci.UseHighlightGuides = !Globals.Settings.HighlightGuide;
sci.Indent = Globals.Settings.IndentSize;
sci.SmartIndentType = Globals.Settings.SmartIndentType;
sci.IsBackSpaceUnIndents = Globals.Settings.BackSpaceUnIndents;
sci.IsCaretLineVisible = Globals.Settings.CaretLineVisible;
sci.IsIndentationGuides = Globals.Settings.ViewIndentationGuides;
sci.IsTabIndents = Globals.Settings.TabIndents;
sci.IsUseTabs = Globals.Settings.UseTabs;
sci.IsViewEOL = Globals.Settings.ViewEOL;
sci.ScrollWidth = Globals.Settings.ScrollWidth;
sci.TabWidth = Globals.Settings.TabWidth;
sci.ViewWS = Convert.ToInt32(Globals.Settings.ViewWhitespace);
sci.WrapMode = Convert.ToInt32(Globals.Settings.WrapText);
sci.SetProperty("fold", Convert.ToInt32(Globals.Settings.UseFolding).ToString());
sci.SetProperty("fold.comment", Convert.ToInt32(Globals.Settings.FoldComment).ToString());
sci.SetProperty("fold.compact", Convert.ToInt32(Globals.Settings.FoldCompact).ToString());
sci.SetProperty("fold.preprocessor", Convert.ToInt32(Globals.Settings.FoldPreprocessor).ToString());
sci.SetProperty("fold.at.else", Convert.ToInt32(Globals.Settings.FoldAtElse).ToString());
sci.SetProperty("fold.html", Convert.ToInt32(Globals.Settings.FoldHtml).ToString());
sci.SetFoldFlags((Int32)Globals.Settings.FoldFlags);
/**
* Set correct line number margin width
*/
Boolean viewLineNumbers = Globals.Settings.ViewLineNumbers;
if (viewLineNumbers) sci.SetMarginWidthN(1, 31);
else sci.SetMarginWidthN(1, 0);
/**
* Set correct bookmark margin width
*/
Boolean viewBookmarks = Globals.Settings.ViewBookmarks;
if (viewBookmarks) sci.SetMarginWidthN(0, 14);
else sci.SetMarginWidthN(0, 0);
/**
* Set correct folding margin width
*/
Boolean useFolding = Globals.Settings.UseFolding;
if (!useFolding && !viewBookmarks && !viewLineNumbers) sci.SetMarginWidthN(2, 0);
else if (useFolding) sci.SetMarginWidthN(2, 15);
else sci.SetMarginWidthN(2, 2);
/**
* Adjust the print margin
*/
sci.EdgeColumn = Globals.Settings.PrintMarginColumn;
if (sci.EdgeColumn > 0) sci.EdgeMode = 1;
else sci.EdgeMode = 0;
/**
* Add missing ignored keys
*/
Int32 count = Globals.MainForm.IgnoredKeys.Count;
for (Int32 i = 0; i < count; i++)
{
Keys keys = (Keys)Globals.MainForm.IgnoredKeys[i];
if (!sci.ContainsIgnoredKeys(keys))
{
sci.AddIgnoredKeys(keys);
}
}
String lang = sci.ConfigurationLanguage;
sci.ConfigurationLanguage = lang;
sci.Colourise(0, -1);
sci.Refresh();
}
catch (Exception ex)
{
ErrorManager.ShowError(ex);
}
}
示例4: ChangeSyntax
/// <summary>
/// Changes the current document's language
/// </summary>
public static void ChangeSyntax(String lang, ScintillaControl sci)
{
sci.StyleClearAll();
sci.StyleResetDefault();
sci.ClearDocumentStyle();
sci.ConfigurationLanguage = lang;
sci.Colourise(0, -1);
sci.Refresh();
ButtonManager.UpdateFlaggedButtons();
Globals.MainForm.OnSyntaxChange(lang);
}
示例5: ApplySciSettings
public static void ApplySciSettings(ScintillaControl sci, Boolean hardUpdate)
{
try
{
sci.CaretPeriod = Globals.Settings.CaretPeriod;
sci.CaretWidth = Globals.Settings.CaretWidth;
sci.EOLMode = LineEndDetector.DetectNewLineMarker(sci.Text, (Int32)Globals.Settings.EOLMode);
sci.IsBraceMatching = Globals.Settings.BraceMatchingEnabled;
sci.UseHighlightGuides = !Globals.Settings.HighlightGuide;
sci.Indent = Globals.Settings.IndentSize;
sci.SmartIndentType = Globals.Settings.SmartIndentType;
sci.IsBackSpaceUnIndents = Globals.Settings.BackSpaceUnIndents;
sci.IsCaretLineVisible = Globals.Settings.CaretLineVisible;
sci.IsIndentationGuides = Globals.Settings.ViewIndentationGuides;
sci.IndentView = Globals.Settings.IndentView;
sci.IsTabIndents = Globals.Settings.TabIndents;
sci.IsUseTabs = Globals.Settings.UseTabs;
sci.IsViewEOL = Globals.Settings.ViewEOL;
sci.ScrollWidth = Globals.Settings.ScrollWidth;
sci.TabWidth = Globals.Settings.TabWidth;
sci.ViewWS = Convert.ToInt32(Globals.Settings.ViewWhitespace);
sci.WrapMode = Convert.ToInt32(Globals.Settings.WrapText);
sci.SetProperty("fold", Convert.ToInt32(Globals.Settings.UseFolding).ToString());
sci.SetProperty("fold.comment", Convert.ToInt32(Globals.Settings.FoldComment).ToString());
sci.SetProperty("fold.compact", Convert.ToInt32(Globals.Settings.FoldCompact).ToString());
sci.SetProperty("fold.preprocessor", Convert.ToInt32(Globals.Settings.FoldPreprocessor).ToString());
sci.SetProperty("fold.at.else", Convert.ToInt32(Globals.Settings.FoldAtElse).ToString());
sci.SetProperty("fold.html", Convert.ToInt32(Globals.Settings.FoldHtml).ToString());
sci.SetProperty("lexer.cpp.track.preprocessor", "0");
sci.SetVirtualSpaceOptions((Int32)Globals.Settings.VirtualSpaceMode);
sci.SetFoldFlags((Int32)Globals.Settings.FoldFlags);
/**
* Set if themes should colorize the first margin
*/
Language language = SciConfig.GetLanguage(sci.ConfigurationLanguage);
if (language != null && language.editorstyle != null)
{
Boolean colorizeMarkerBack = language.editorstyle.ColorizeMarkerBack;
if (colorizeMarkerBack) sci.SetMarginTypeN(0, (Int32)MarginType.Fore);
else sci.SetMarginTypeN(0, (Int32)MarginType.Symbol);
}
/**
* Set correct line number margin width
*/
Boolean viewLineNumbers = Globals.Settings.ViewLineNumbers;
if (viewLineNumbers) sci.SetMarginWidthN(1, ScaleArea(sci, 36));
else sci.SetMarginWidthN(1, 0);
/**
* Set correct bookmark margin width
*/
Boolean viewBookmarks = Globals.Settings.ViewBookmarks;
if (viewBookmarks) sci.SetMarginWidthN(0, ScaleArea(sci, 14));
else sci.SetMarginWidthN(0, 0);
/**
* Set correct folding margin width
*/
Boolean useFolding = Globals.Settings.UseFolding;
if (!useFolding && !viewBookmarks && !viewLineNumbers) sci.SetMarginWidthN(2, 0);
else if (useFolding) sci.SetMarginWidthN(2, ScaleArea(sci, 15));
else sci.SetMarginWidthN(2, ScaleArea(sci, 2));
/**
* Adjust the print margin
*/
sci.EdgeColumn = Globals.Settings.PrintMarginColumn;
if (sci.EdgeColumn > 0) sci.EdgeMode = 1;
else sci.EdgeMode = 0;
/**
* Add missing ignored keys
*/
foreach (Keys keys in ShortcutManager.AllShortcuts)
{
if (keys != Keys.None && !sci.ContainsIgnoredKeys(keys))
{
sci.AddIgnoredKeys(keys);
}
}
if (hardUpdate)
{
String lang = sci.ConfigurationLanguage;
sci.ConfigurationLanguage = lang;
}
sci.Colourise(0, -1);
sci.Refresh();
}
catch (Exception ex)
{
ErrorManager.ShowError(ex);
}
}
示例6: Execute
public void Execute()
{
Sci = PluginBase.MainForm.CurrentDocument.SciControl;
Sci.BeginUndoAction();
try
{
IASContext context = ASContext.Context;
Int32 pos = Sci.CurrentPos;
string expression = Sci.SelText.Trim(new char[] { '=', ' ', '\t', '\n', '\r', ';', '.' });
expression = expression.TrimEnd(new char[] { '(', '[', '{', '<' });
expression = expression.TrimStart(new char[] { ')', ']', '}', '>' });
cFile = ASContext.Context.CurrentModel;
ASFileParser parser = new ASFileParser();
parser.ParseSrc(cFile, Sci.Text);
MemberModel current = cFile.Context.CurrentMember;
string characterClass = ScintillaControl.Configuration.GetLanguage(Sci.ConfigurationLanguage).characterclass.Characters;
int funcBodyStart = ASGenerator.GetBodyStart(current.LineFrom, current.LineTo, Sci);
Sci.SetSel(funcBodyStart, Sci.LineEndPosition(current.LineTo));
string currentMethodBody = Sci.SelText;
bool isExprInSingleQuotes = (expression.StartsWith("'") && expression.EndsWith("'"));
bool isExprInDoubleQuotes = (expression.StartsWith("\"") && expression.EndsWith("\""));
int stylemask = (1 << Sci.StyleBits) - 1;
int lastPos = -1;
char prevOrNextChar;
Sci.Colourise(0, -1);
while (true)
{
lastPos = currentMethodBody.IndexOf(expression, lastPos + 1);
if (lastPos > -1)
{
if (lastPos > 0)
{
prevOrNextChar = currentMethodBody[lastPos - 1];
if (characterClass.IndexOf(prevOrNextChar) > -1)
{
continue;
}
}
if (lastPos + expression.Length < currentMethodBody.Length)
{
prevOrNextChar = currentMethodBody[lastPos + expression.Length];
if (characterClass.IndexOf(prevOrNextChar) > -1)
{
continue;
}
}
int style = Sci.StyleAt(funcBodyStart + lastPos) & stylemask;
if (ASComplete.IsCommentStyle(style))
{
continue;
}
else if ((isExprInDoubleQuotes && currentMethodBody[lastPos] == '"' && currentMethodBody[lastPos + expression.Length - 1] == '"')
|| (isExprInSingleQuotes && currentMethodBody[lastPos] == '\'' && currentMethodBody[lastPos + expression.Length - 1] == '\''))
{
}
else if (!ASComplete.IsTextStyle(style))
{
continue;
}
Sci.SetSel(funcBodyStart + lastPos, funcBodyStart + lastPos + expression.Length);
Sci.ReplaceSel(NewName);
currentMethodBody = currentMethodBody.Substring(0, lastPos) + NewName + currentMethodBody.Substring(lastPos + expression.Length);
lastPos += NewName.Length;
}
else
{
break;
}
}
Sci.CurrentPos = funcBodyStart;
Sci.SetSel(Sci.CurrentPos, Sci.CurrentPos);
string snippet = "var " + NewName + ":$(EntryPoint) = " + expression + ";\n$(Boundary)";
SnippetHelper.InsertSnippetText(Sci, Sci.CurrentPos, snippet);
}
finally
{
Sci.EndUndoAction();
}
}
示例7: GenerateExtractVariable
public static void GenerateExtractVariable(ScintillaControl sci, string newName)
{
string expression = sci.SelText.Trim(new char[] { '=', ' ', '\t', '\n', '\r', ';', '.' });
expression = expression.TrimEnd(new char[] { '(', '[', '{', '<' });
expression = expression.TrimStart(new char[] { ')', ']', '}', '>' });
var cFile = ASContext.Context.CurrentModel;
ASFileParser parser = new ASFileParser();
parser.ParseSrc(cFile, sci.Text);
MemberModel current = cFile.Context.CurrentMember;
string characterClass = ScintillaControl.Configuration.GetLanguage(sci.ConfigurationLanguage).characterclass.Characters;
int funcBodyStart = GetBodyStart(current.LineFrom, current.LineTo, sci);
sci.SetSel(funcBodyStart, sci.LineEndPosition(current.LineTo));
string currentMethodBody = sci.SelText;
var insertPosition = funcBodyStart + currentMethodBody.IndexOfOrdinal(expression);
var line = sci.LineFromPosition(insertPosition);
insertPosition = sci.LineIndentPosition(line);
int lastPos = -1;
sci.Colourise(0, -1);
while (true)
{
lastPos = currentMethodBody.IndexOfOrdinal(expression, lastPos + 1);
if (lastPos > -1)
{
char prevOrNextChar;
if (lastPos > 0)
{
prevOrNextChar = currentMethodBody[lastPos - 1];
if (characterClass.IndexOf(prevOrNextChar) > -1)
{
continue;
}
}
if (lastPos + expression.Length < currentMethodBody.Length)
{
prevOrNextChar = currentMethodBody[lastPos + expression.Length];
if (characterClass.IndexOf(prevOrNextChar) > -1)
{
continue;
}
}
var pos = funcBodyStart + lastPos;
int style = sci.BaseStyleAt(pos);
if (ASComplete.IsCommentStyle(style)) continue;
sci.SetSel(pos, pos + expression.Length);
sci.ReplaceSel(newName);
currentMethodBody = currentMethodBody.Substring(0, lastPos) + newName + currentMethodBody.Substring(lastPos + expression.Length);
lastPos += newName.Length;
}
else
{
break;
}
}
sci.CurrentPos = insertPosition;
sci.SetSel(sci.CurrentPos, sci.CurrentPos);
MemberModel m = new MemberModel(newName, "", FlagType.LocalVar, 0);
m.Value = expression;
string snippet = TemplateUtils.GetTemplate("Variable");
snippet = TemplateUtils.ReplaceTemplateVariable(snippet, "Modifiers", null);
snippet = TemplateUtils.ToDeclarationString(m, snippet);
snippet += NewLine + "$(Boundary)";
SnippetHelper.InsertSnippetText(sci, sci.CurrentPos, snippet);
}