使用CrystalEdit做一个文本编辑器

本文档介绍了如何使用CrystalEdit构建文本编辑器,包括CCrystalTextView和CCrystalEditView类的使用,以及如何处理文本缓冲区、解析和语法高亮。编辑操作被拆分为插入和删除文本的基本操作,以支持撤销/重做功能。同时,讨论了在没有缓冲类的情况下如何使用CCrystalTextView,并提供了实现示例。
摘要由CSDN通过智能技术生成
The package consists of three main classes:
  • CCrystalTextBuffer class is responsible for storing lines, loading and saving text to a file. To simplify Undo/Redo command implementations, every editing operation is split into a sequence of 'insert text' and 'delete text' actions. Accordingly, CView-derived classes are only intended to react only on this primitive operations.

  • CCrystalTextView class is the framework for text viewing window. It derives from CView, and it provides text painting code, overridable functions for syntax highlighting, different kinds of text selections, cursor movements, Find common dialog etc. However, it's not allowed to perform any changes to the text.

    CCrystalTextView-derived views are usually used with CCrystalTextBuffer object. Once such a view is connected to the CCrystalTextBuffer object, it is capable to track changes made to the text. (Obviously, any number of views can be connected to a single CCrystalTextBuffer object at the same time. This is useful, when we need to use the editor in the dynamic splitter as shown on the figure above).

  • CCrystalEditView class is derived from CCrystalTextView class. Unlike its ansector, which is only able to display a text and update the view when it is needed, it has functions to perform all sorts of editing, including drag-and-drop and Replace dialog. Note, that the view does not make the changes in the text directly, instead, it transforms the command into a sequence of primitive operations described above, and delegates them to the CCrystalTextBuffer object. Once the changes are made, the CCrystalTextBuffer object updates all views connected to it.

Usually, CCrystalTextBuffer exists within the CDocument object. You must provide a way to connect views to the object (the best place for it is
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值