本文整理汇总了C#中ScintillaNet.ScintillaControl.GetLine方法的典型用法代码示例。如果您正苦于以下问题:C# ScintillaControl.GetLine方法的具体用法?C# ScintillaControl.GetLine怎么用?C# ScintillaControl.GetLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ScintillaNet.ScintillaControl
的用法示例。
在下文中一共展示了ScintillaControl.GetLine方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsMethod
private static bool IsMethod(ScintillaControl sci, string name)
{
if (!Regex.IsMatch(name, "^[a-z0-9_]+$", RegexOptions.IgnoreCase))
return false;
string line = sci.GetLine(sci.CurrentLine);
string pattern = "\\bfunction\\s+" + Regex.Escape(name) + "\\s*\\(";
return Regex.IsMatch(line, pattern);
}
示例2: FindNewVarPosition
private static int FindNewVarPosition(ScintillaControl sci, ClassModel inClass, MemberModel latest)
{
firstVar = false;
// found a var?
if ((latest.Flags & FlagType.Variable) > 0)
return sci.PositionFromLine(latest.LineTo + 1) - ((sci.EOLMode == 0) ? 2 : 1);
// add as first member
int line = 0;
int maxLine = sci.LineCount;
if (inClass != null)
{
line = inClass.LineFrom;
maxLine = inClass.LineTo;
}
else if (ASContext.Context.InPrivateSection) line = ASContext.Context.CurrentModel.PrivateSectionIndex;
else maxLine = ASContext.Context.CurrentModel.PrivateSectionIndex;
while (line < maxLine)
{
string text = sci.GetLine(line++);
if (text.IndexOf('{') >= 0)
{
firstVar = true;
return sci.PositionFromLine(line) - ((sci.EOLMode == 0) ? 2 : 1);
}
}
return -1;
}
示例3: GenerateVariableJob
private static void GenerateVariableJob(GeneratorJobType job, ScintillaControl sci, MemberModel member,
bool detach, ClassModel inClass)
{
int position = 0;
MemberModel latest = null;
bool isOtherClass = false;
Visibility varVisi = job.Equals(GeneratorJobType.Variable) ? GetDefaultVisibility(inClass) : Visibility.Public;
FlagType ft = job.Equals(GeneratorJobType.Constant) ? FlagType.Constant : FlagType.Variable;
// evaluate, if the variable (or constant) should be generated in other class
ASResult varResult = ASComplete.GetExpressionType(sci, sci.WordEndPosition(sci.CurrentPos, true));
int contextOwnerPos = GetContextOwnerEndPos(sci, sci.WordStartPosition(sci.CurrentPos, true));
MemberModel isStatic = new MemberModel();
if (contextOwnerPos != -1)
{
ASResult contextOwnerResult = ASComplete.GetExpressionType(sci, contextOwnerPos);
if (contextOwnerResult != null)
{
if (contextOwnerResult.Member == null && contextOwnerResult.Type != null)
{
isStatic.Flags |= FlagType.Static;
}
}
}
else if (member != null && (member.Flags & FlagType.Static) > 0)
{
isStatic.Flags |= FlagType.Static;
}
ASResult returnType = null;
int lineNum = sci.CurrentLine;
string line = sci.GetLine(lineNum);
Match m = Regex.Match(line, "\\b" + Regex.Escape(contextToken) + "\\(");
if (m.Success)
{
returnType = new ASResult();
returnType.Type = ASContext.Context.ResolveType("Function", null);
}
else
{
m = Regex.Match(line, @"=\s*[^;\n\r}}]+");
if (m.Success)
{
int posLineStart = sci.PositionFromLine(lineNum);
if (posLineStart + m.Index >= sci.CurrentPos)
{
line = line.Substring(m.Index);
StatementReturnType rType = GetStatementReturnType(sci, inClass, line, posLineStart + m.Index);
if (rType != null)
{
returnType = rType.resolve;
}
}
}
}
if (varResult.RelClass != null && !varResult.RelClass.IsVoid() && !varResult.RelClass.Equals(inClass))
{
AddLookupPosition();
lookupPosition = -1;
ASContext.MainForm.OpenEditableDocument(varResult.RelClass.InFile.FileName, false);
sci = ASContext.CurSciControl;
isOtherClass = true;
FileModel fileModel = new FileModel();
fileModel.Context = ASContext.Context;
ASFileParser parser = new ASFileParser();
parser.ParseSrc(fileModel, sci.Text);
foreach (ClassModel cm in fileModel.Classes)
{
if (cm.QualifiedName.Equals(varResult.RelClass.QualifiedName))
{
varResult.RelClass = cm;
break;
}
}
inClass = varResult.RelClass;
ASContext.Context.UpdateContext(inClass.LineFrom);
}
latest = GetLatestMemberForVariable(job, inClass, varVisi, isStatic);
// if we generate variable in current class..
if (!isOtherClass && member == null)
{
detach = false;
lookupPosition = -1;
position = sci.WordStartPosition(sci.CurrentPos, true);
sci.SetSel(position, sci.WordEndPosition(position, true));
}
else // if we generate variable in another class
{
if (latest != null)
{
//.........这里部分代码省略.........
示例4: EventMetatag
private static void EventMetatag(ClassModel inClass, ScintillaControl sci, MemberModel member)
{
ASResult resolve = ASComplete.GetExpressionType(sci, sci.WordEndPosition(sci.CurrentPos, true));
string line = sci.GetLine(inClass.LineFrom);
int position = sci.PositionFromLine(inClass.LineFrom) + (line.Length - line.TrimStart().Length);
string value = resolve.Member.Value;
if (value != null)
{
if (value.StartsWith('\"'))
{
value = value.Trim(new char[] { '"' });
}
else if (value.StartsWith('\''))
{
value = value.Trim(new char[] { '\'' });
}
}
else value = resolve.Member.Type;
if (string.IsNullOrEmpty(value))
return;
Regex re1 = new Regex("'(?:[^'\\\\]|(?:\\\\\\\\)|(?:\\\\\\\\)*\\\\.{1})*'");
Regex re2 = new Regex("\"(?:[^\"\\\\]|(?:\\\\\\\\)|(?:\\\\\\\\)*\\\\.{1})*\"");
Match m1 = re1.Match(value);
Match m2 = re2.Match(value);
if (m1.Success || m2.Success)
{
Match m = null;
if (m1.Success && m2.Success) m = m1.Index > m2.Index ? m2 : m1;
else if (m1.Success) m = m1;
else m = m2;
value = value.Substring(m.Index + 1, m.Length - 2);
}
string template = TemplateUtils.GetTemplate("EventMetatag");
template = TemplateUtils.ReplaceTemplateVariable(template, "Name", value);
template = TemplateUtils.ReplaceTemplateVariable(template, "Type", contextParam);
template += "\n$(Boundary)";
AddLookupPosition();
sci.CurrentPos = position;
sci.SetSel(position, position);
InsertCode(position, template, sci);
}
示例5: OnChar
/// <summary>
/// Handles the incoming character
/// </summary>
public static void OnChar(ScintillaControl sci, Int32 value)
{
if (cType == XMLType.Invalid || (sci.ConfigurationLanguage != "xml" && sci.ConfigurationLanguage != "html"))
return;
XMLContextTag ctag;
Int32 position = sci.CurrentPos;
if (sci.BaseStyleAt(position) == 6 && value != '"')
return; // in XML attribute
Char c = ' ';
DataEvent de;
switch (value)
{
case 10:
// Shift+Enter to insert <BR/>
Int32 line = sci.LineFromPosition(position);
if (Control.ModifierKeys == Keys.Shift)
{
ctag = GetXMLContextTag(sci, position);
if (ctag.Tag == null || ctag.Tag.EndsWith(">"))
{
int start = sci.PositionFromLine(line)-((sci.EOLMode == 0)? 2:1);
sci.SetSel(start, position);
sci.ReplaceSel((PluginSettings.UpperCaseHtmlTags) ? "<BR/>" : "<br/>");
sci.SetSel(start+5, start+5);
return;
}
}
if (PluginSettings.SmartIndenter)
{
// Get last non-empty line
String text = "";
Int32 line2 = line - 1;
while (line2 >= 0 && text.Length == 0)
{
text = sci.GetLine(line2).TrimEnd();
line2--;
}
if ((text.EndsWith(">") && !text.EndsWith("?>") && !text.EndsWith("%>") && !closingTag.IsMatch(text)) || text.EndsWith("<!--") || text.EndsWith("<![CDATA["))
{
// Get the previous tag
do
{
position--;
c = (Char)sci.CharAt(position);
}
while (position > 0 && c != '>');
ctag = GetXMLContextTag(sci, c == '>' ? position + 1 : position);
if ((Char)sci.CharAt(position-1) == '/') return;
// Insert blank line if we pressed Enter between a tag & it's closing tag
Int32 indent = sci.GetLineIndentation(line2 + 1);
String checkStart = null;
bool subIndent = true;
if (text.EndsWith("<!--")) { checkStart = "-->"; subIndent = false; }
else if (text.EndsWith("<![CDATA[")) { checkStart = "]]>"; subIndent = false; }
else if (ctag.Closed) subIndent = false;
else if (ctag.Name != null)
{
checkStart = "</" + ctag.Name;
if (ctag.Name.ToLower() == "script" || ctag.Name.ToLower() == "style")
subIndent = false;
if (ctag.Tag.IndexOf('\r') > 0 || ctag.Tag.IndexOf('\n') > 0)
subIndent = false;
}
if (checkStart != null)
{
text = sci.GetLine(line).TrimStart();
if (text.StartsWith(checkStart))
{
sci.SetLineIndentation(line, indent);
sci.InsertText(sci.PositionFromLine(line), LineEndDetector.GetNewLineMarker(sci.EOLMode));
}
}
// Indent the code
if (subIndent) indent += sci.Indent;
sci.SetLineIndentation(line, indent);
position = sci.LineIndentPosition(line);
sci.SetSel(position, position);
return;
}
}
break;
case '<':
case '/':
if (value == '/')
{
if ((position < 2) || ((Char)sci.CharAt(position-2) != '<')) return;
ctag = new XMLContextTag();
ctag.Closing = true;
}
else
{
ctag = GetXMLContextTag(sci, position);
if (ctag.Tag != null) return;
}
// Allow another plugin to handle this
//.........这里部分代码省略.........
示例6: GetTemplateBlockMember
public static MemberModel GetTemplateBlockMember(ScintillaControl Sci, string blockTmpl)
{
if (string.IsNullOrEmpty(blockTmpl))
return null;
string firstLine = blockTmpl;
int lineCount = 0;
int index = blockTmpl.IndexOf('\n');
if (index != -1)
{
firstLine = blockTmpl.Substring(0, index);
lineCount = Regex.Matches(blockTmpl, "\n").Count;
}
int lineNum = 0;
while (lineNum < Sci.LineCount)
{
string line = Sci.GetLine(lineNum);
int funcBlockIndex = line.IndexOfOrdinal(firstLine);
if (funcBlockIndex != -1)
{
MemberModel latest = new MemberModel();
latest.LineFrom = lineNum;
latest.LineTo = lineNum;
latest.LineTo = lineNum + lineCount;
return latest;
}
lineNum++;
}
return null;
}
示例7: ContextualGenerator
public static void ContextualGenerator(ScintillaControl Sci, List<ICompletionListItem> options)
{
if (ASContext.Context is ASContext) (ASContext.Context as ASContext).UpdateCurrentFile(false); // update model
if ((ASContext.Context.CurrentClass.Flags & (FlagType.Enum | FlagType.TypeDef)) > 0) return;
lookupPosition = -1;
int position = Sci.CurrentPos;
int style = Sci.BaseStyleAt(position);
if (style == 19) // on keyword
return;
bool isNotInterface = (ASContext.Context.CurrentClass.Flags & FlagType.Interface) == 0;
int line = Sci.LineFromPosition(position);
contextToken = Sci.GetWordFromPosition(position);
contextMatch = null;
FoundDeclaration found = GetDeclarationAtLine(Sci, line);
string text = Sci.GetLine(line);
bool suggestItemDeclaration = false;
if (isNotInterface && ASComplete.IsLiteralStyle(style))
{
ShowConvertToConst(found, options);
return;
}
ASResult resolve = ASComplete.GetExpressionType(Sci, Sci.WordEndPosition(position, true));
contextResolved = resolve;
// ignore automatic vars (MovieClip members)
if (isNotInterface
&& resolve.Member != null
&& (((resolve.Member.Flags & FlagType.AutomaticVar) > 0) || (resolve.InClass != null && resolve.InClass.QualifiedName == "Object")))
{
resolve.Member = null;
resolve.Type = null;
}
if (isNotInterface && found.inClass != ClassModel.VoidClass && contextToken != null)
{
if (resolve.Member == null && resolve.Type != null
&& (resolve.Type.Flags & FlagType.Interface) > 0) // implement interface
{
contextParam = resolve.Type.Type;
ShowImplementInterface(found, options);
return;
}
if (resolve.Member != null && !ASContext.Context.CurrentClass.IsVoid()
&& (resolve.Member.Flags & FlagType.LocalVar) > 0) // promote to class var
{
contextMember = resolve.Member;
ShowPromoteLocalAndAddParameter(found, options);
return;
}
}
if (contextToken != null && resolve.Member == null) // import declaration
{
if ((resolve.Type == null || resolve.Type.IsVoid() || !ASContext.Context.IsImported(resolve.Type, line)) && CheckAutoImport(found, options)) return;
if (resolve.Type == null)
{
suggestItemDeclaration = ASComplete.IsTextStyle(Sci.BaseStyleAt(position - 1));
}
}
if (isNotInterface && found.member != null)
{
// private var -> property
if ((found.member.Flags & FlagType.Variable) > 0 && (found.member.Flags & FlagType.LocalVar) == 0)
{
// maybe we just want to import the member's non-imported type
Match m = Regex.Match(text, String.Format(patternVarDecl, found.member.Name, contextToken));
if (m.Success)
{
contextMatch = m;
ClassModel type = ASContext.Context.ResolveType(contextToken, ASContext.Context.CurrentModel);
if (type.IsVoid() && CheckAutoImport(found, options))
return;
}
ShowGetSetList(found, options);
return;
}
// inside a function
else if ((found.member.Flags & (FlagType.Function | FlagType.Getter | FlagType.Setter)) > 0
&& resolve.Member == null && resolve.Type == null)
{
if (contextToken != null)
{
// "generate event handlers" suggestion
string re = String.Format(patternEvent, contextToken);
Match m = Regex.Match(text, re, RegexOptions.IgnoreCase);
if (m.Success)
{
contextMatch = m;
contextParam = CheckEventType(m.Groups["event"].Value);
ShowEventList(found, options);
return;
}
m = Regex.Match(text, String.Format(patternAS2Delegate, contextToken), RegexOptions.IgnoreCase);
//.........这里部分代码省略.........
示例8: RenameMember
public static bool RenameMember(ScintillaControl Sci, MemberModel member, string newName)
{
ContextFeatures features = ASContext.Context.Features;
string kind = features.varKey;
if ((member.Flags & FlagType.Getter) > 0)
kind = features.getKey;
else if ((member.Flags & FlagType.Setter) > 0)
kind = features.setKey;
else if (member.Flags == FlagType.Function)
kind = features.functionKey;
Regex reMember = new Regex(String.Format(@"{0}\s+({1})[\s:]", kind, member.Name));
string line;
Match m;
int index, position;
for (int i = member.LineFrom; i <= member.LineTo; i++)
{
line = Sci.GetLine(i);
m = reMember.Match(line);
if (m.Success)
{
index = Sci.MBSafeTextLength(line.Substring(0, m.Groups[1].Index));
position = Sci.PositionFromLine(i) + index;
Sci.SetSel(position, position + member.Name.Length);
Sci.ReplaceSel(newName);
UpdateLookupPosition(position, 1);
return true;
}
}
return false;
}
示例9: OnCharAdded
internal void OnCharAdded(ScintillaControl sci, int position, int value)
{
if (!enabled) return;
bool autoInsert = false;
char c = (char)value;
if (wordChars.IndexOf(c) < 0)
{
if (c == ':')
{
if (lastColonInsert == position - 1)
{
sci.DeleteBack();
lastColonInsert = -1;
return;
}
}
else if (c == ';')
{
char c2 = (char)sci.CharAt(position);
if (c2 == ';')
{
sci.DeleteBack();
sci.SetSel(position, position);
return;
}
}
else if (c == '\n' && !settings.DisableAutoCloseBraces)
{
int line = sci.LineFromPosition(position);
string text = sci.GetLine(line - 1).TrimEnd();
if (text.EndsWith("{")) AutoCloseBrace(sci, line);
}
else if (c == '\t') // TODO get tab notification!
{
position--;
autoInsert = true;
}
else return;
}
var context = GetContext(sci, position);
var mode = CompleteMode.None;
if (context.InComments) return;
else if (context.InBlock)
{
if (context.Word == "-") mode = CompleteMode.Prefix;
else if (context.Word.Length >= 2 || (char)value == '-')
mode = CompleteMode.Attribute;
}
else if (context.InValue)
{
if (features.Mode != "CSS" && c == features.Trigger)
{
context.Word = context.Word.Substring(1);
context.Position++;
mode = CompleteMode.Variable;
}
else if (context.Word.Length == 1 && "abcdefghijklmnopqrstuvwxyz".IndexOf(context.Word[0]) >= 0)
mode = CompleteMode.Value;
}
else if (c == ':' && !context.IsVar) mode = CompleteMode.Pseudo;
HandleCompletion(mode, context, autoInsert, true);
}
示例10: ParseBlocks
private List<CssBlock> ParseBlocks(ScintillaControl sci)
{
List<CssBlock> blocks = new List<CssBlock>();
blocks.Clear();
int lines = sci.LineCount;
int inString = 0;
bool inComment = false;
CssBlock block = null;
for (int i = 0; i < lines; i++)
{
string line = sci.GetLine(i);
int len = line.Length;
int safeLen = len - 1;
for (int j = 0; j < len; j++)
{
char c = line[j];
if (inComment)
{
if (c == '*' && j < safeLen && line[j + 1] == '/') inComment = false;
else continue;
}
else if (inString > 0)
{
if (inString == 1 && c == '\'') inString = 0;
else if (inString == 2 && c == '"') inString = 0;
else continue;
}
else if (c == '\'') inString = 1;
else if (c == '"') inString = 2;
else if (c == '/' && j < safeLen && line[j + 1] == '/')
break;
else if (c == '/' && j < safeLen && line[j + 1] == '*')
inComment = true;
else if (c == '{')
{
CssBlock parent = block;
block = new CssBlock();
block.LineFrom = i;
block.ColFrom = j;
if (parent != null)
{
block.Parent = parent;
parent.Children.Add(block);
}
else blocks.Add(block);
}
else if (c == '}')
{
if (block != null)
{
block.LineTo = i;
block.ColTo = j;
block = block.Parent;
if (block != null)
{
block.LineTo = i;
block.ColTo = j;
}
}
}
}
}
return blocks;
}
示例11: IsVarDecl
private bool IsVarDecl(ScintillaControl sci, int i)
{
if (features.Pattern == null) return false;
int line = sci.LineFromPosition(i);
string text = sci.GetLine(line);
return features.Pattern.IsMatch(text);
}
示例12: MBSafeColumn
/// <summary>
/// Convert multibyte column to byte length
/// </summary>
private int MBSafeColumn(ScintillaControl sci, int line, int length)
{
String text = sci.GetLine(line) ?? "";
length = Math.Min(length, text.Length);
return sci.MBSafeTextLength(text.Substring(0, length));
}
示例13: IsMethoDecl
private static bool IsMethoDecl(ScintillaControl sci)
{
string line = sci.GetLine(sci.CurrentLine);
return Regex.IsMatch(line, "\\bfunction\\b");
}
示例14: IsMethodBodyStart
private static bool IsMethodBodyStart(ScintillaControl sci)
{
string line = sci.GetLine(sci.CurrentLine);
int openBrace = line.LastIndexOf('{');
return openBrace > 0 && openBrace > line.LastIndexOf('}') && openBrace > line.LastIndexOf(')');
}
示例15: RemoveOneLocalDeclaration
private static bool RemoveOneLocalDeclaration(ScintillaControl sci, MemberModel contextMember)
{
string type = "";
if (contextMember.Type != null && (contextMember.Flags & FlagType.Inferred) == 0)
{
type = FormatType(contextMember.Type);
if (type.IndexOf('*') > 0)
type = type.Replace("/*", @"/\*\s*").Replace("*/", @"\s*\*/");
type = @":\s*" + type;
}
Regex reDecl = new Regex(String.Format(@"[\s\(]((var|const)\s+{0}\s*{1})\s*", contextMember.Name, type));
for (int i = contextMember.LineFrom; i <= contextMember.LineTo + 10; i++)
{
string text = sci.GetLine(i);
Match m = reDecl.Match(text);
if (m.Success)
{
int index = sci.MBSafeTextLength(text.Substring(0, m.Groups[1].Index));
int position = sci.PositionFromLine(i) + index;
int len = sci.MBSafeTextLength(m.Groups[1].Value);
sci.SetSel(position, position + len);
if (contextMember.Type == null || (contextMember.Flags & FlagType.Inferred) != 0) sci.ReplaceSel(contextMember.Name + " ");
else sci.ReplaceSel(contextMember.Name);
UpdateLookupPosition(position, contextMember.Name.Length - len);
return true;
}
}
return false;
}