本文整理汇总了C#中IHighlightingDefinition类的典型用法代码示例。如果您正苦于以下问题:C# IHighlightingDefinition类的具体用法?C# IHighlightingDefinition怎么用?C# IHighlightingDefinition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IHighlightingDefinition类属于命名空间,在下文中一共展示了IHighlightingDefinition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PythonConsoleHighlightingColorizer
/// <summary>
/// Creates a new HighlightingColorizer instance.
/// </summary>
/// <param name="ruleSet">The root highlighting rule set.</param>
public PythonConsoleHighlightingColorizer(IHighlightingDefinition highlightingDefinition, TextDocument document)
: base(new DocumentHighlighter(document, highlightingDefinition ))
{
if (document == null)
throw new ArgumentNullException("document");
this.document = document;
}
示例2: GetCompletionDatas
public IList<ICompletionData> GetCompletionDatas(IHighlightingDefinition language) {
if (language == null) return null;
if (dataDict.ContainsKey(language)) return dataDict[language];
dataDict.Add(language, new List<ICompletionData>());
var datas = dataDict[language];
//以后ecp格式改用自己定义的xml格式
string path = Path.Combine( _cfgPath,language.Name);
if (Directory.Exists(path) == false) return datas;
foreach(string file in Directory.GetFiles(path)) {
using (StreamReader sr = new StreamReader(file)) {
//这里改用xmlSerialize
//To Do
try {
LoadData(datas, sr);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
continue;
}
}
}
return datas;
}
示例3: CodeBlock
public CodeBlock(FsiSession session, IHighlightingDefinition syntaxHighlighting)
{
this.Document = new TextDocument("");
this.session = session;
this.syntaxHighlighting = syntaxHighlighting;
this.run = new RelayCommand(OnRun, CanRun);
}
示例4: MainWindow
public MainWindow()
{
// Load our custom highlighting definition
//IHighlightingDefinition customHighlighting;
using (Stream s = typeof(MainWindow).Assembly.GetManifestResourceStream("TestWpfC.CustomHighlighting.xshd"))
{
if (s == null)
throw new InvalidOperationException("Could not find embedded resource");
using (XmlReader reader = new XmlTextReader(s))
{
customHighlighting = ICSharpCode.AvalonEdit.Highlighting.Xshd.
HighlightingLoader.Load(reader, HighlightingManager.Instance);
}
}
// and register it in the HighlightingManager
HighlightingManager.Instance.RegisterHighlighting("Custom Highlighting", new string[] { ".cool" }, customHighlighting);
InitializeComponent();
textEditor.SyntaxHighlighting = customHighlighting;
HighlightingComboBox_SelectionChanged(null, null);
//textEditor.TextArea.TextEntering += textEditor_TextArea_TextEntering;
//textEditor.TextArea.TextEntered += textEditor_TextArea_TextEntered;
DispatcherTimer foldingUpdateTimer = new DispatcherTimer();
foldingUpdateTimer.Interval = TimeSpan.FromSeconds(2);
foldingUpdateTimer.Tick += foldingUpdateTimer_Tick;
foldingUpdateTimer.Start();
}
示例5: GetDefinition
IHighlightingDefinition GetDefinition()
{
Func<IHighlightingDefinition> func;
lock (lockObj) {
if (this.definition != null)
return this.definition;
func = this.lazyLoadingFunction;
}
Exception exception = null;
IHighlightingDefinition def = null;
try {
using (var busyLock = BusyManager.Enter(this)) {
if (!busyLock.Success)
throw new InvalidOperationException("Tried to create delay-loaded highlighting definition recursively. Make sure the are no cyclic references between the highlighting definitions.");
def = func();
}
if (def == null)
throw new InvalidOperationException("Function for delay-loading highlighting definition returned null");
} catch (Exception ex) {
exception = ex;
}
lock (lockObj) {
this.lazyLoadingFunction = null;
if (this.definition == null && this.storedException == null) {
this.definition = def;
this.storedException = exception;
}
if (this.storedException != null)
throw new HighlightingDefinitionInvalidException("Error delay-loading highlighting definition", this.storedException);
return this.definition;
}
}
示例6: Decompile
void Decompile(ModuleDef module, BamlDocument document, Language lang,
ITextOutput output, out IHighlightingDefinition highlight, CancellationToken token) {
var decompiler = new XamlDecompiler();
var xaml = decompiler.Decompile(module, document, token);
output.Write(xaml.ToString(), TextTokenType.Text);
highlight = HighlightingManager.Instance.GetDefinitionByExtension(".xml");
}
示例7: ThemedHighlightingColorizer
/// <summary>
/// Creates a new HighlightingColorizer instance.
/// </summary>
/// <param name="definition">The highlighting definition.</param>
public ThemedHighlightingColorizer(IHighlightingDefinition definition)
: this()
{
if (definition == null)
throw new ArgumentNullException("definition");
this.definition = definition;
}
示例8: ScriptEditorViewModel
public ScriptEditorViewModel(string name, string content, IHighlightingDefinition highlighting)
{
Name = name;
Content = content;
CurrentText = new StringText(content);
Highlighting = highlighting;
References = new BindableCollection<string>();
UsingStatements = new BindableCollection<string>();
}
示例9: ConvertTextDocumentToBlock
/// <summary>
/// Converts a readonly TextDocument to a Block and applies the provided highlighting definition.
/// </summary>
public static Block ConvertTextDocumentToBlock(ReadOnlyDocument document, IHighlightingDefinition highlightingDefinition)
{
IHighlighter highlighter;
if (highlightingDefinition != null)
highlighter = new DocumentHighlighter(document, highlightingDefinition);
else
highlighter = null;
return ConvertTextDocumentToBlock(document, highlighter);
}
示例10: SetFolding
/// <summary>
/// Determine whether or not highlighting can be
/// suppported by a particular folding strategy.
/// </summary>
/// <param name="syntaxHighlighting"></param>
public void SetFolding(IHighlightingDefinition syntaxHighlighting)
{
if (syntaxHighlighting == null)
{
this.mFoldingStrategy = null;
}
else
{
switch (syntaxHighlighting.Name)
{
case "XML":
case "HTML":
mFoldingStrategy = new XmlFoldingStrategy() { ShowAttributesWhenFolded = true };
this.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy();
break;
case "C#":
this.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.CSharp.CSharpIndentationStrategy(this.Options);
mFoldingStrategy = new CSharpBraceFoldingStrategy();
break;
case "C++":
case "PHP":
case "Java":
this.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.CSharp.CSharpIndentationStrategy(this.Options);
mFoldingStrategy = new CSharpBraceFoldingStrategy();
break;
case "VBNET":
this.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.CSharp.CSharpIndentationStrategy(this.Options);
mFoldingStrategy = new VBNetFoldingStrategy();
break;
default:
this.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy();
mFoldingStrategy = null;
break;
}
if (mFoldingStrategy != null)
{
if (this.Document != null)
{
if (mFoldingManager == null)
mFoldingManager = FoldingManager.Install(this.TextArea);
this.mFoldingStrategy.UpdateFoldings(mFoldingManager, this.Document);
}
else
this.mInstallFoldingManager = true;
}
else
{
if (mFoldingManager != null)
{
FoldingManager.Uninstall(mFoldingManager);
mFoldingManager = null;
}
}
}
}
示例11: DocumentHighlighter
/// <summary>
/// Creates a new DocumentHighlighter instance.
/// </summary>
public DocumentHighlighter(ReadOnlyDocument document, IHighlightingDefinition definition)
{
if (document == null)
throw new ArgumentNullException("document");
if (definition == null)
throw new ArgumentNullException("definition");
this.document = document;
this.definition = definition;
InvalidateHighlighting();
}
示例12: DocumentHighlighter
/// <summary>
/// Creates a new DocumentHighlighter instance.
/// </summary>
public DocumentHighlighter(TextDocument document, IHighlightingDefinition definition)
{
if (document == null)
throw new ArgumentNullException("document");
if (definition == null)
throw new ArgumentNullException("definition");
this.document = document;
this.definition = definition;
this.engine = new HighlightingEngine(definition.MainRuleSet);
document.VerifyAccess();
weakLineTracker = WeakLineTracker.Register(document, this);
InvalidateSpanStacks();
}
示例13: GetCompletionDatas
public IList<ICompletionData> GetCompletionDatas(IHighlightingDefinition language) {
if (language == null) return null;
if (datas!=null) return datas;
datas = new List<ICompletionData>();
//以后ecp格式改用自己定义的xml格式
string path = _cfgPath;
using (StreamReader sr = new StreamReader(string.Format(path, language.Name, language.Name))) {
while (sr.EndOfStream == false) {
string line = sr.ReadLine();
string[] snappets = line.Split('|');
DefaultCompletionData data;
if (snappets.Length == 2)
data = new DefaultCompletionData() { Text=snappets[0],Description=snappets[1],Content=snappets[0]};
else
data = new DefaultCompletionData() { Text = snappets[0], Content = snappets[0] };
datas.Add(data);
}
}
return datas;
}
示例14: RegisterHighlighting
/// <summary>
/// Registers a highlighting definition.
/// </summary>
/// <param name="name">The name to register the definition with.</param>
/// <param name="extensions">The file extensions to register the definition for.</param>
/// <param name="highlighting">The highlighting definition.</param>
public void RegisterHighlighting(string name, string[] extensions, IHighlightingDefinition highlighting)
{
if (highlighting == null)
throw new ArgumentNullException("highlighting");
lock (lockObj) {
allHighlightings.Add(highlighting);
if (name != null) {
highlightingsByName[name] = highlighting;
}
if (extensions != null) {
foreach (string ext in extensions) {
highlightingsByExtension[ext] = highlighting;
}
}
}
}
示例15: SetHighlighter
/// <summary>
/// Sets the Syntax Highlighter to a specific Highlighter
/// </summary>
/// <param name="def">Highlighting Definition</param>
public void SetHighlighter(IHighlightingDefinition def)
{
String syntax;
if (this._enableHighlighting)
{
this._editor.SyntaxHighlighting = def;
syntax = (this._editor.SyntaxHighlighting == null) ? "None" : def.Name;
}
else
{
syntax = def.Name;
}
this._currSyntax = syntax;
this.SetCurrentHighlighterChecked(syntax);
this.SetCurrentValidator(syntax);
this.SetCurrentAutoCompleter(syntax);
}