AvalonEdit 对于选定的文本添加前缀和后缀
1: /// <summary>2: /// 两边追加标志3: /// </summary>4: /// <param name="syntax"></param>5: public void ToggleSymmetricalMarkdownFormatting(string syntax)6: {7: int selectionLength = this.textEditor.SelectionLength;8: int selectionStart = this.textEditor.SelectionStart;9: if (selectionLength == 0 && selectionStart + syntax.Length <= this.textEditor.Text.Length)10: {11: string text = this.textEditor.Document.GetText(selectionStart, syntax.Length);12: if (text == syntax)13: {14: this.textEditor.SelectionStart += syntax.Length;15: return;16: }17: }18: char[] array = syntax.ToCharArray();19: Array.Reverse(array);20: string text2 = new string(array);21: int num = this.textEditor.SelectionLength;22: int num2 = this.textEditor.SelectionStart;23: if (num2 >= syntax.Length)24: {25: num2 -= syntax.Length;26: num += syntax.Length;27: }28: DocumentLine lineByOffset = this.textEditor.Document.GetLineByOffset(this.textEditor.CaretOffset);29: if (num2 + num + syntax.Length <= lineByOffset.EndOffset)30: {31: num += syntax.Length;32: }33: string text3 = "";34: if (num > 0)35: {36: text3 = this.textEditor.Document.GetText(num2, num);37: }38: Match match = Regex.Match(text3, string.Concat(new string[]39: {40: "^",41: Regex.Escape(syntax),42: "(.*)",43: Regex.Escape(text2),44: "$"45: }), RegexOptions.Singleline);46: bool success = match.Success;47: if (success)48: {49: text3 = match.Groups[1].Value;50: this.textEditor.SelectionStart = num2;51: this.textEditor.SelectionLength = num;52: this.textEditor.SelectedText = text3;53: return;54: }55: text3 = syntax + this.textEditor.SelectedText + text2;56: this.textEditor.SelectedText = text3;57: this.textEditor.SelectionLength -= syntax.Length * 2;58: this.textEditor.SelectionStart += syntax.Length;59: }
1: /// <summary>2: /// 左边添加前缀3: /// </summary>4: /// <param name="markdownSyntaxToApply"></param>5: public void ToggleAsymmetricMarkdownFormatting(string markdownSyntaxToApply)6: {7: bool flag = this.textEditor.SelectedText == this.textEditor.Document.GetText(this.CurrentLine);8: bool flag2 = this.textEditor.SelectedText.Contains(Environment.NewLine);9: bool flag3 = this.textEditor.CaretOffset == this.CurrentLine.Offset;10: if ((!flag3 || !flag) && !flag2)11: {12: this.textEditor.SelectedText = Environment.NewLine + this.textEditor.SelectedText;13: this.textEditor.SelectionLength -= Environment.NewLine.Length;14: this.textEditor.SelectionStart += Environment.NewLine.Length;15: }16: if (this.textEditor.SelectionLength > 0)17: {18: string selectedText = this.textEditor.SelectedText;19: string selectedText2;20: if (selectedText.Contains(markdownSyntaxToApply))21: {22: selectedText2 = selectedText.Replace(markdownSyntaxToApply, "");23: }24: else25: {26: selectedText2 = markdownSyntaxToApply + selectedText.Replace(Environment.NewLine, Environment.NewLine + markdownSyntaxToApply);27: }28: this.textEditor.SelectedText = selectedText2;29: return;30: }31: DocumentLine lineByOffset = this.textEditor.Document.GetLineByOffset(this.textEditor.CaretOffset);32: string text = string.Empty;33: if (!(lineByOffset.Length == 0))34: {35: text = Environment.NewLine;36: }37: this.textEditor.SelectedText = text + markdownSyntaxToApply;38: this.textEditor.SelectionLength = 0;39: this.textEditor.SelectionStart += markdownSyntaxToApply.Length + text.Length;40: }41: public DocumentLine CurrentLine42: {43: get44: {45: return this.textEditor.Document.GetLineByOffset(this.textEditor.CaretOffset);46: }47: }48:
AvalonEdit 对于选定的文本添加前缀和后缀的更多相关文章
- excel给一列数据添加前缀和后缀
1.选中一列单元格后设置单元格格式,在自定义中输入-----“前缀”@(前缀为需要添加的内容) 输入----@“后缀” 2.字符串拼接:“前缀”&B1,B1&“后缀”
- Xcode常用技巧(2)-使Xcode在创建类时自动添加前缀
在Xcode5之前的版本中,Xcode在新建项目时,会要求为一个类指定一个前缀,这样方便我们区分相同名字的类.而从Xcode6开始,由于Swift增加了命名空间的关系,Xcode在新建项目时,不会再要 ...
- 在Navicat 中给Mysql中的某字段添加前缀00
第一次分享心得,希望大家多多关注. 我遇到的情况是这样的,在Navicat中某表的varchar字段内容长度不够5的在内容前面添加‘0’:如字段内容是 101 我就要改成00101: 其中有2个难点: ...
- css之为文本添加线性渐变和外描边
css之为文本添加线性渐变和外描边 一.效果: 描边:描边+渐变: 二.描边: api:text-stroke 问题:text-stroke的描边是居中描边,无法直接设置外描边 解决:在before ...
- iOS: 在Xcode7系列中给类名自动添加前缀
添加前缀原因: 我个人还是很喜欢 Class Prefix 的,因为: 1. 使用它几乎不增加什么成本, 2. 不使用它可能会造成安全隐患, 3. 它能够以直接的方式编码一些信息以供未来的回溯, 4. ...
- 用Emmet写CSS3属性会自动添加前缀
CSS3的很多属性都包含浏览器厂商前缀,用Emmet写CSS3属性会自动添加前缀,比如输入trs 会展开为: -webkit-transition: prop time; -moz-transitio ...
- 我的Android进阶之旅------> Android为TextView组件中显示的文本添加背景色
通过上一篇文章 我的Android进阶之旅------> Android在TextView中显示图片方法 (地址:http://blog.csdn.net/ouyang_peng/article ...
- webpack css文件编译、自动添加前缀、剥离
1.css文件编译 webpack默认只能编译js文件,引入css需要loader支持 // css文件写入js中 npm i style-loader -D // css文件loader npm i ...
- Makefile中的$(addprefix),添加前缀,指定目标生成目录
先给大家看段Makefile的代码吧: INCLUDE_DIR=usr/java/jdk1..0_25/include \ usr/java/jdk1..0_25/include/linux INCL ...
随机推荐
- linux grep常用参数
# grep [-acinv] [--color=auto] '搜寻字符串' filename选项与参数:-c :计算找到 '搜寻字符串' 的次数-i :忽略大小写的不同,所以大小写视为相同-n :顺 ...
- LINUX更改时区和时间
因为公司运营海外游戏,服务器也多数放在国外,有时候要求服务器时区和时间要与所服务的地区一致,这里就涉及到更改服务器时区和时间的问题: 下面以一台在美国的服务器为例,我们的IDC提供商是一家德国公司,服 ...
- 退出应用 关闭多个Activity
Activity3 public class Activity3 extends ListActivity { protected void onCreate(Bundle savedInst ...
- noip 2005 等价表达式
/* 开始想的是 维护a的每个指数的系数 然而不好办 然而还有^10^10^10这种数据 特殊值带入吧 多搞几个素数 接下来就是玄学的事了 给a赋值之后 就是简单地表达式求值 虽然思路简单 但是字符串 ...
- 转载-- C/S 与 B/S 区别
C/S 与 B/S 区别 C/S结构,即Client/Server(客户机/服务器)结构,是大家熟知的软件系统体系结构,通过将任务合理分配到Client端和Server端,降低了系统的通讯开销,可 ...
- ajax请求在ie8下缓存问题
我今天在改项目bug的时候,发现ajax请求在ie8下有缓存,在缓存过期之前,针对相同地址发起的多个Ajax请求,只有第一次会真正发送到服务端.在某些情况下,这种默认的缓存机制并不是我们希望的(比如获 ...
- PHP 单链表
<?php class Hero { public $no; public $name; public $nickname; public $next=null; public function ...
- 关于.net类型转换判断问题
做项目时,发现这个问题,由于数据库中的字段可能为null,如果在.net程序直接转换时,比如 ltTime.Text =DateTime.Parse(dt.Rows[0]["m_Time&q ...
- ORACLE外键和锁
在oracle中,如果外键未加索引,对父表的修改,会导致子表被加上全表锁.这包括两种情况: 1.删除父表中的行,如果外键上没有索引,会导致子表被加上全表锁 2.更新父表的主键(根据关系数据库的原则,更 ...
- ORA-19502: write error on file "/u01/app/oracle/oradata/standby/system01.dbf", blockno 40321 (blocksize=8192)【error收集】
在RMAN备份中,出现了一个问题,就是出现坏块了. ORA-: write error on file (blocksize=) ORA-: File I/O error Linux Error: : ...