📄 bufferoptions.cs
字号:
// BufferOptions.cs
// Copyright (c) 2001 Mike Krueger
//
// 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 2 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, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
using System;
using System.Drawing;
using System.Reflection;
using System.Xml;
using SharpDevelop.Tool.Data;
namespace SharpDevelop.Internal.Text {
public enum LineViewerStyle {
None,
FullRow
}
public class BufferOptions : ICloneable, XmlConvertable
{
bool autoinsertcurlybracket = true;
bool showeolmarkers = false;
bool showlinenumbers = true;
bool showinvalidlines = true;
bool showtabs = false;
bool showspaces = false;
bool showvruler = false;
bool showhruler = false;
int hrulerrow = 80;
int tabindent = 4;
bool tabstospaces = false;
bool hidemousecursor = false;
bool cursorbehindeol = false;
bool useantialiasfont = false;
bool showerrors = true;
bool autoinserttemplates = true;
LineViewerStyle lineviewerstyle;
IndentStyle indent = IndentStyle.Smart;
public event EventHandler OptionChanged;
public bool AutoInsertCurlyBracket {
get {
return autoinsertcurlybracket;
}
set {
autoinsertcurlybracket = value;
OnChanged();
}
}
public bool AutoInsertTemplates {
get {
return autoinserttemplates;
}
set {
autoinserttemplates = value;
OnChanged();
}
}
public Font DefaultFont {
get {
return FontContainer.DefaultFont;
}
set {
FontContainer.DefaultFont = value;
OnChanged();
}
}
public bool ShowErrors {
get {
return showerrors;
}
set {
showerrors = value;
OnChanged();
}
}
public bool UseAntiAliasFont {
get {
return useantialiasfont;
}
set {
useantialiasfont = value;
OnChanged();
}
}
public bool ShowVRuler {
get {
return showvruler;
}
set {
showvruler = value;
OnChanged();
}
}
public LineViewerStyle LineViewerStyle {
get {
return lineviewerstyle;
}
set {
lineviewerstyle = value;
OnChanged();
}
}
public bool CursorBehindEOL {
get {
return cursorbehindeol;
}
set {
cursorbehindeol = value;
OnChanged();
}
}
public bool HideMouseCursor {
get {
return hidemousecursor;
}
set {
hidemousecursor = value;
OnChanged();
}
}
public bool TabsToSpaces {
get {
return tabstospaces;
}
set {
tabstospaces = value;
OnChanged();
}
}
public int TabIndent {
get {
return tabindent;
}
set {
tabindent = value;
OnChanged();
}
}
public int HRulerRrow {
get {
return hrulerrow;
}
set {
hrulerrow = value;
OnChanged();
}
}
public bool ShowHRuler {
get {
return showhruler;
}
set {
showhruler = value;
OnChanged();
}
}
public IndentStyle IndentStyle {
get {
return indent;
}
set {
indent = value;
OnChanged();
}
}
public bool ShowSpaces {
get {
return showspaces;
}
set {
showspaces = value;
OnChanged();
}
}
public bool ShowTabs {
get {
return showtabs;
}
set {
showtabs = value;
OnChanged();
}
}
public bool ShowEOLMarkers {
get {
return showeolmarkers;
}
set {
showeolmarkers = value;
OnChanged();
}
}
public bool ShowInvalidLines {
get {
return showinvalidlines;
}
set {
showinvalidlines = value;
OnChanged();
}
}
public bool ShowLineNumbers {
get {
return showlinenumbers;
}
set {
showlinenumbers = value;
OnChanged();
}
}
public BufferOptions()
{
}
public BufferOptions(XmlElement element)
{
if (element == null)
throw new ArgumentNullException("element can't be null");
PropertyInfo[] properties = typeof(BufferOptions).GetProperties();
foreach (PropertyInfo property in properties) {
XmlElement el = element[property.Name];
object obj = null;
if (property.PropertyType == typeof(bool))
obj = Boolean.Parse(el.InnerText);
else
if (property.PropertyType == typeof(int))
obj = Int32.Parse(el.InnerText);
else
if (property.PropertyType == typeof(LineViewerStyle))
obj = Enum.Parse(typeof(LineViewerStyle), el.InnerText);
else
if (property.PropertyType == typeof(IndentStyle))
obj = Enum.Parse(typeof(IndentStyle), el.InnerText);
else
if (property.PropertyType == typeof(Font)) {
// TODO : font reading
string txt = el.InnerText.Substring(30); // hack to read courier font size
string nr = "";
for (int i = 0; i < txt.Length;++i)
if (Char.IsDigit(txt[i]))
nr += txt[i];
else
break;
Console.WriteLine(nr);
DefaultFont = new Font("Courier New", Int32.Parse(nr));
continue;
}
else
throw new ApplicationException("Unknown type in BufferOptions!");
property.SetValue(this, obj, null);
}
}
void OnChanged()
{
if (OptionChanged != null)
OptionChanged(this, null);
}
public object Clone()
{
return MemberwiseClone();
}
public object FromXmlElement(XmlElement element)
{
return new BufferOptions(element);
}
public XmlElement ToXmlElement(XmlDocument doc)
{
XmlElement el = doc.CreateElement("BufferOptions");
PropertyInfo[] properties = typeof(BufferOptions).GetProperties();
foreach (PropertyInfo property in properties) {
XmlElement child = doc.CreateElement(property.Name);
child.InnerText = property.GetValue(this, null).ToString();
el.AppendChild(child);
}
return el;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -