| 0: | // TextWord.cs | |
| 1: | // Copyright (c) 2000 Mike Krueger | |
| 2: | // | |
| 3: | // This program is free software; you can redistribute it and/or modify | |
| 4: | // it under the terms of the GNU General Public License as published by | |
| 5: | // the Free Software Foundation; either version 2 of the License, or | |
| 6: | // (at your option) any later version. | |
| 7: | // | |
| 8: | // This program is distributed in the hope that it will be useful, | |
| 9: | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 10: | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 11: | // GNU General Public License for more details. | |
| 12: | // | |
| 13: | // You should have received a copy of the GNU General Public License | |
| 14: | // along with this program; if not, write to the Free Software | |
| 15: | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 16: | ||
| 17: | using System; | |
| 18: | using System.Drawing; | |
| 19: | ||
| 20: | namespace SharpDevelop.Internal.Text { | |
| 21: | ||
| 22: | public enum TextWordType { | |
| 23: | Word, | |
| 24: | Space, | |
| 25: | Tab | |
| 26: | } | |
| 27: | ||
| 28: | ||
| 29: | /// <summary> | |
| 30: | /// This class represents single words with color information, two special versions of a word are | |
| 31: | /// spaces and tabs. | |
| 32: | /// </summary> | |
| 33: | public class TextWord | |
| 34: | { | |
| 35: | SyntaxColor color; | |
| 36: | string word; | |
| 37: | string myword = null; | |
| 38: | int offset; | |
| 39: | int length; | |
| 40: | TextWordType type; | |
| 41: | ||
| 42: | public bool NotMarked = false; | |
| 43: | ||
| 44: | // TAB | |
| 45: | public TextWord(TextWordType type) | |
| 46: | { | |
| 47: | this.type = type; | |
| 48: | } | |
| 49: | ||
| 50: | public TextWord(string word, int offset, int length, Syntax syntax, SyntaxColor color) | |
| 51: | { | |
| 52: | this.word = word; | |
| 53: | this.offset = offset; | |
| 54: | this.length = length; | |
| 55: | ||
| 56: | if (color == null) { | |
| 57: | NotMarked = true; | |
| 58: | this.color = syntax.defaultColor; | |
| 59: | } else | |
| 60: | this.color = color; | |
| 61: | this.type = TextWordType.Word; | |
| 62: | } | |
| 63: | ||
| 64: | public TextWordType Type { | |
| 65: | get { | |
| 66: | return type; | |
| 67: | } | |
| 68: | } | |
| 69: | public string Word { | |
| 70: | get { | |
| 71: | if (myword == null) | |
| 72: | myword = word.Substring(offset, length); | |
| 73: | return myword; | |
| 74: | } | |
| 75: | } | |
| 76: | ||
| 77: | public Font Font { | |
| 78: | get { | |
| 79: | return color.Font; | |
| 80: | } | |
| 81: | } | |
| 82: | ||
| 83: | public Color Color { | |
| 84: | get { | |
| 85: | return color.Color; | |
| 86: | } | |
| 87: | } | |
| 88: | public SyntaxColor SyntaxColor { | |
| 89: | get { | |
| 90: | return color; | |
| 91: | } | |
| 92: | set { | |
| 93: | color = value; | |
| 94: | } | |
| 95: | } | |
| 96: | } | |
| 97: | ||
| 98: | } |
This page was automatically generated by SharpDevelop.