sourcecodechildform.cs
来自「本软件是针对PL/x语法结构设计的PL/x编译器」· CS 代码 · 共 60 行
CS
60 行
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace PLX
{
public partial class SourceCodeChildForm : Form
{
public SourceCodeChildForm()
{
InitializeComponent();
}
private void rtxtSourceCode_KeyPress(object sender, KeyPressEventArgs e)
{
//判读回车符,增加行号
if (e.KeyChar == 13)
{
ChangeLineNum();
}
//判断Delete,Backspace,减少行号
if (e.KeyChar == 46 || e.KeyChar == 8)
{
ChangeLineNum();
}
}
private void ChangeLineNum()
{
//Get first LineNum of current textbox
Point pos = new Point(0,rtxtSourceCode.Font.Height);
int firstIndex = rtxtSourceCode.GetCharIndexFromPosition(pos);
int firstLineNum = rtxtSourceCode.GetLineFromCharIndex(firstIndex) + 1;
//Get last lineNum of current textbox
pos.X = ClientRectangle.Width;
pos.Y = ClientRectangle.Height;
int lastIndex = rtxtSourceCode.GetCharIndexFromPosition(pos);
int lastLineNum = rtxtSourceCode.GetLineFromCharIndex(lastIndex) + 1;
Form1.BuildLineNum(firstLineNum , lastLineNum);
}
private void rtxtSourceCode_TextChanged(object sender, EventArgs e)
{
ChangeLineNum();
}
private void rtxtSourceCode_VScroll(object sender, EventArgs e)
{
ChangeLineNum();
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?