/* * Copyright (C) 2013 FooProject * * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or (at your option) any later version. * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ using System; namespace FooEditEngine { /// /// トークンのタイプを表す /// public enum TokenType { /// /// どのカテゴリーにも属さないトークンを表す /// None = 0, /// /// キーワード1として表示するトークンを表す /// Keyword1, /// /// キーワード2として表示するトークンを表す /// Keyword2, /// /// コメントとして表示するトークンを表す /// Comment, /// /// 文字リテラルとして表示するトークンを表す /// Literal, /// /// コントロールとして表示するトークンを表す /// Control, } /// /// イベントデータを表す /// public class TokenSpilitEventArgs { /// /// 単語長 /// public int length; /// /// トークンのタイプ /// public TokenType type; /// /// トークンの切り出しをやめるなら真をセットし、そうでないなら偽をセットする(規定値は偽) /// public bool breaked; /// /// トークンがあるインデックス /// public int index; /// /// コンストラクター /// public TokenSpilitEventArgs() { } /// /// コンストラクター /// /// 開始インデックス /// 長さ /// トークンタイプ public TokenSpilitEventArgs(int index,int length, TokenType type) { this.length = length; this.type = type; this.index = index; this.breaked = false; } } /// /// トークンが切り出された時に呼ばれるイベント /// /// イベントデータ /// public delegate void TokenSpilitHandeler(TokenSpilitEventArgs state); /// /// シンタックスハイライトを行うためのインターフェイス /// public interface IHilighter { /// /// 初期状態に戻す /// void Reset(); /// /// ハイライト処理を実行します /// /// 対象となる文字列 /// 文字列の長さ /// トークンが切り出されたときに呼び出されるデリゲート /// エンクロージャーレベル。開始エンクロージャーだけを検出した場合は1以上の値を返し、 /// 終了エンクロージャーだけを検出した場合を-1以下の値を返すようにします。 /// 何も検出しなかった場合、開始エンクロージャーと終了エンクロージャーが対になっている場合、 /// エンクロージャー内で開始エンクロージャーを検出した場合は0を返します /// なお、開始エンクロージャーがすでに検出されている状態で検出したことを返した場合、その結果は無視されます /// /// /// int DoHilight(string text,int length, TokenSpilitHandeler action) /// { /// if(length > 3 && text == "foo") /// action(new TokenSpilitEventArgs(0,3,TokenType.Keyword1); /// return 0; /// } /// int DoHilight(string text,int length, TokenSpilitHandeler action); } }