跨平台编辑器控件

发布于 2024-07-07 21:54:47 字数 1557 浏览 3 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

把昨日还给我 2024-07-14 21:54:47

正如 John 所写,Scintilla 可以在 OS X 上运行。
现在,如果您正在寻找的话,它不是一个富文本组件。 它是一个源代码编辑器:您不能将任意颜色应用于任意文本段,它使用词法分析器来设置内容样式。

您没有告诉我们您的用例是什么。

[编辑] 感谢您添加用例。

免责声明 1:我并不是试图“推销”Scintilla,我只是试图向您提供有关我熟悉的组件的信息,希望对您有所帮助... :-D
请注意,相关站点页面列出了许多替代编辑组件,这些组件包括:可能很有趣(也可能不是,其中很多仅适用于 Win32)。
免责声明 2:我没有在 Win32 平台之外使用 Scintilla 的经验。

但是查看源代码树,我看到一个 scintilla/macosx 文件夹。 除此之外,它还有一个带有 main.cpp 文件的 SciTest 子文件夹。 尽管它有扩展,但对我来说它看起来非常像纯 C。 因此,它可以作为如何在 C 中使用 Scintilla 的示例。

请注意,根据设计,Scintilla API 非常有限:它最初是通过向其发送消息来用作大多数传统 Win32 组件的。 Scintilla 文档 页面仅列出这些消息及其参数。 main.cpp 示例使用 MacOS X 风格的组件创建窗口,并使用诸如 scintilla->WndProc(SCI_STYLESETFORE, 0, 0x808080); 之类的行发送命令;

我不会声称它可以完成您所要做的所有事情需要,或者即使它在 MacOS X 上完美运行,您也必须进行实验(或询问改编的作者)才能确定。
此外,Scintilla 不会提供工具栏或侧边栏面板(这更多地属于应用程序本身)。 但我认为它可以提供足够的通知来帮助您将这些辅助组件保持在上下文中。
您还需要为您的语法编写一个特定的词法分析器(此处为 C++)。 如果你看看其他词法分析器是如何工作的,这并不难。 也许您会找到一种足够接近的语言可以用作起点。
也许人们感兴趣的是将文档的某些部分设置为只读的功能,尽管我相信这还没有经过彻底的测试。

HTH。

As John wrote, Scintilla is known to run on OS X.
Now, it is not a rich text component, if that's what you are looking for. It is a source code editor: you can't apply arbitrary colors to arbitrary segments of text, it uses a lexer to style the content.

You didn't tell us what is your use case.

[EDIT] Thanks for adding the use case.

Disclaimer 1: I don't try to "sell" Scintilla, I just try to provide you information about a component I know well, hoping that helps you... :-D
Note that the Related Sites page lists a number of alternative Editing Components which can be interesting (or not, lot of them are for Win32 only).
Disclaimer 2: I have no experience of using Scintilla outside of the Win32 platform.

But looking at the source tree, I see a scintilla/macosx folder. Among other things, it has a SciTest sub-folder with a main.cpp file. Despite its extension, it strongly looks like pure C for me. So it can be an example of how to use Scintilla in C.

Note that by design, Scintilla API is very limited: it was initially made to be used as most traditional Win32 components, by sending messages to it. The Scintilla Documentation page only lists these messages and their parameters. The main.cpp example creates the window with the component in MacOS X style and sends commands with lines like scintilla->WndProc(SCI_STYLESETFORE, 0, 0x808080);

I won't claim it does everything you need, or even that it works flawlessly on MacOS X, you have to experiment (or ask the author of the adaptation) to be sure.
Also Scintilla won't provide a toolbar nor a sidebar panel (this belongs more to the application itself). But I think it can provide enough notifications to help you keeping these side components on context.
You will need also to write a specific lexer (C++ here) for your syntax. It isn't hard if you look how works other lexers. Perhaps you will find one for a language close enough to be used as a starting point.
Perhaps of interest too is a feature to set some portions of document as read-only, although I believe this haven't been thoroughly tested.

HTH.

著墨染雨君画夕 2024-07-14 21:54:47

Scintilla 及其后代(无 OS X)

但是,scintilla 确实可以在 OS X 上运行。


您可以使用 GtkTextView,或 Qt 的 QTextEdit

Scintilla and descendants (no OS X)

But, scintilla does work on OS X.


You could try GTK+ with GtkTextView, or Qt's QTextEdit.

柠檬色的秋千 2024-07-14 21:54:47

FLTK 的 TextEditor 小部件就是您所需要的。 它简单、直接、易于使用,具有 utf8,您可以轻松拥有文本样式。 只需几行,您就可以拥有一个编辑器。 检查 /test/editor.cxx 示例。 它在 OSX 上也能完美运行。 此外,您需要的一切都在这里解释: http://www.fltk.org/doc -1.1/editor.html

FLTK's TextEditor widget is all you need. It is simple, straightforward, and easy to use, has utf8 and you can easily have text-styles. With just few lines you can have an editor. Check the /test/editor.cxx example. It works perfectly on OSX as well. Furthermore, all you need is explained here: http://www.fltk.org/doc-1.1/editor.html .

悲歌长辞 2024-07-14 21:54:47

出色地,
你也许可以使用 tk - 文本小部件据说很好而且灵活 - 看看tcl/tk wiki

或者您可以使用一些嵌入式/游戏工具包(例如 Agar) - 但有一个具有编辑功能的文本小部件我想会更麻烦。

但对我来说,说你想做一个跨平台的 C GUI,然后放弃 GTK,这似乎是浪费大量的时间和精力。 您可能最终会切换语言或使用 GTK。

Well,
you might be able to use tk -- the text widget is supposedly good and flexible -- have a looksie at the tcl/tk wiki.

Or you could go for some embedded/game toolkit (like Agar) -- but there a text widget with editing capabilities would be more cumbersome, I imagine.

But saying you want to do a cross-platform C GUI and then writing off GTK seems like a whole lot of wasted time and effort, to me. You'll probably end up switching languages or using GTK.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文