文本/代码编辑器,行很长 [英] Text/Code Editor for really long lines

查看:114
本文介绍了文本/代码编辑器,行很长的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我正在寻找一种在某种文本框中显示很长的文本行的方法.用于二进制数据模式的脚本/宏语言.它处理非常简单的宏以定义数据流以及一些排序功能.但是,我的程序允许将部分宏扩展到最终数据流中,然后再次编辑脚本(例如,为了调试目的插入位错误).麻烦来了:扩展的宏可能导致很长的代码行,超出了TextBox或RichTextBox的可能性.

是的,我可以将代码分成几行,但这不是我想要的.如果用户定义了两行代码,导致产生一兆位的二进制数据,那么他将获得一兆位的二进制数据.而且他可以在文本编辑器中获取它,因为还有更多的语义可能要编辑.

使用TextBox对其进行编辑是行不通的,因为即使WordWrap设置为false,该控件也会包裹很长的行. RichTextBox具有相同的行为,尽管它在包裹太长的行之前具有较大的阈值.

换行导致错误的行号,因为每个换行都具有一个新的行号.我需要行号来告诉用户在哪里查找语法错误.

我尝试将Fireball设置为ScintillaNet,但两者似乎都存在问题,尤其是在文本行较长的情况下.

有人有主意吗?是针对TextBox或RichTextBox的修复程序,还是完全没有自动换行功能,或者至少在换行后至少具有正确的行号的有效编辑器组件?语法高亮也很酷,但这并不紧急.

如果它是组件/控件,则需要带有允许在商业产品中使用它的许可证(因此没有GPL).

Hi there,

I''m looking for a way to display very long text lines in some kind of a text box. It''s for a scripting/macro language for binary data patterns. It handles very simple macros to define a data stream, together with some sequencing features. However, my program allows to expand part of the macros into the final data stream, then editing the script again (e.g. to insert bit errors for debugging purposes). Here comes the trouble: the expanded macros can lead to very long code lines, exceeding the possibilities of a TextBox or RichTextBox.

Yep, I could butcher the code down into shorter lines, but that''s not what I want. If the user defines a two-line-code leading to one megabit of binary data, he gets one megabit of binary data. And he gets it in a text editor, since there is more semantics remaining he might want to edit.

Editing this with a TextBox doesn''t work, because that control wraps very long lines, even if WordWrap is set to false. A RichTextBox has the same behavior, although it has a larger threshold before it wraps too long lines.

The wrapping leads to incorrect line numbers, because every wrapped line has a new line number. I need the line numbers to tell the user where to look for syntax errors.

I tried Fireball an ScintillaNet, but both seem to be buggy, especially with that long text lines.

Does anybody have an idea? A fix for TextBox or RichTextBox, or a working editor component with no word-wrapping at all, or at least with correct line number after wrapping? Syntax Highlighting would also be cool, but that''s not urgent.

If it''s a component/control, I need it with a license that allows to use it in a commercial product (so no GPL).

推荐答案

奇怪的要求.我认为您可能想考虑您的方法.仅显示很长的行可能不是理想的情况.

就解决方案而言,您要么要寻找第三部分控件,要么弯曲自己的控件.我在Windows中使用C#的工作很少(大多数是服务,后端处理和asp.net).但是我在C ++中做了很多Windows工作.如果这是C ++,则解决方案是从CWnd 或基本视图之一继承您自己的窗口.我不确定基于TextBoxBase的子类可能对您有帮助.再次,我不是从确凿的证据中谈论.看是否有更高的窗口"对象可以子类化或创建自己的窗口控件.
This is very strange requirement. I think you may want to think your approach. Simply showing very long line may not be the ideal case.

As far are solution, either you have to look for 3rd part control or curve out your own control. I have not worked much with C# in the windows ( most is service, back end processing and asp.net). But I have done a lot of windows in C++. If this was C++ then the solution is to sub class your own window from CWnd or one of the base views. I am not sure sub classing TextBoxBase based may do you much. Again I am not talking from hard evidence. Look if there is higher "window" object you can sub class or create your own window control.


也许您应该只编写一个自定义控件以根据需要显示文本.可能您可以从TextBox派生自己的控件,然后覆盖绘制文本行的方法.在Windows窗体中这不是很多工作,控件将完全按照您想要的做.
Perhaps you should simply write yourself a custom control to display the text as you need it. Probably you can derive your own control from TextBox and then override the method where the text lines are drawn. This is not very much work in Windows Forms and the control will then do exactly what you want.


我确实有一个主意,但这取决于宏的结构.

首先,这是一种使用长行的奇怪的宏语言.让我们考虑一下,给出了.
这是基于文本的语言,不适合普通文本编辑器使用(无论如何都是草率的),否则您不会

这仅表示一长行是一个很大的代码单元.您不想滚动此长行来访问它,这非常不方便.您需要更改演示文稿,并远离文本编辑器的外观.这只是动机.

为什么不在语言表示中添加视觉上明显的结构(而不​​是语言本身)?
如果生产线较长,则应具有更好的结构.使用语言语法在语义上将行解析为子单元.假设您具有两层结构:一行是一个单元,带子单元.

现在,您可以将其显示在TreeView中,每个顶级节点代表一行,下一级节点代表该行中的一个子单元.您可以根据宏语言语法进行更深层次的结构.

—SA
I do have one idea, but it depends on the structure of your macro.

First of all, this is a strange macro language which uses long line. Let''s consider, it''s given.
This is the text-base language which is not designed to be use by normal text editors (which is sloppy, anyway), otherwise you would not

It simply means that a long line is a really big unit of code. You don''t want to scroll this long line to access it, this is extremely inconvenient. You need to change the presentation and go away from text-editor look and feel. This is just a motivation.

Why not adding a visually apparent structure to the language presentation (not language itself)?
If the line is a long unit, it should have finer structure. Parse the line into sub-units, semantically, using the language syntax. Let''s assume you got two-level structure: one line is one unit, with sub-units.

Now you can present it in a TreeView, each top-level node representing a single line, next-level node representing a sub-unit in the line. You can make deeper structure, depending on macro-language syntax.

—SA


这篇关于文本/代码编辑器,行很长的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆