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 ...
随机推荐
- hdu 1022
// hdu1022 这题算是我做的第一道栈的题目,之前看过栈的一些内容,做这道题的时候,可以模拟出过程,但是具体的代码不会写...所以决定练习一些栈和队列的问题,大概思路就是有三个数组和一个栈,先把 ...
- DotNet中的计时器线程计时器
转载自:http://hi.baidu.com/wingingbob/item/9f1c9615f3b24d5f2b3e225c 基于多线程设计,计时器工作在ThreadPool线程上,存在事件的重入 ...
- oracle where与having
where与having可以过滤,一般来说尽量使用where ,但是如果过滤条件中有组函数,只能使用having SQL> select deptno,avg(sal) from emp gro ...
- 你好,C++(30)“大事化小,小事化了”5.4.3 工资程序成长记:函数
5.4.3 工资程序成长记:函数 自从上次小陈“程序员”的工资程序得到老板的夸奖,口头许诺给他涨工资以后,老板再也没有找过他,涨工资的事自然也就没有下文了.这天,老板又突然召他去办公室.这下可把小陈高 ...
- 在线支付接口之PHP支付宝接口开发
支付接口一般是第三方提供的代收款.付款的平台,可以通过支付接口帮助企业或个人利用一切可以使用的支付方式.常见支付平台:支付宝.快钱.云网支付.财付通. 支付宝页面:订单页面.状态页面.返回页面.--- ...
- 图的建立——邻接矩阵表示(C语言+VC6.0平台)
图的邻接矩阵表示及其建立(无向图) #include <stdio.h> #include <stdlib.h> typedef char VertexType; ...
- TFS 如何恢复到指定版本
一. 签出文件,然后获得指定版本. 二. 覆盖本地文件. 三.选择合并冲突. 四. 签入恢复的文件. 五. 解决冲突,选择抛弃服务器版本.
- 转:Raspberry Pi(树莓派)试用小记
近期入手一树莓派卡片机,体验了一下它的强大,写篇报告,推广一下哈! 机器截图: 基础参数: CPU:700 MHz, ARM11 内存:512M(还有一种是256M的) 支持GPU加速(高清视频无压力 ...
- 转:Linux内存管理之mmap详解
一. mmap系统调用 1. mmap系统调用 mmap将一个文件或者其它对象映射进内存.文件被映射到多个页上,如果文件的大小不是所有页的大小之和,最后一个页不被使用的空间将会清零.munmap执行相 ...
- 转:全志A20 GPIO 总结文档
链接: http://blog.csdn.net/chwenj/article/details/42190745 /* * author: chwenj@gmail.com. * A ...