如何更改 Netbeans 预览文档的字体和颜色?

发布于 2024-07-09 21:30:12 字数 917 浏览 9 评论 0 原文

在 Netbeans 6.5 的工具中 -> 选项-> 字体和 颜色 -> 通过语法对话框,您可以更改 Netbeans 文本编辑器的外观。 当您选择一种语言时,您将看到字体/颜色方案的预览。 然而,当我预览 Java 时,语法更改的选项比预览窗口中显示的要多得多。 如果我能够查看更健壮的代码,我就能看到更多选项的直接效果。

如何提供预览文档来查看我的字体/颜色更改?

更新:

经过更多研究后,我已经能够缩小问题范围了。 据我所知,Netbeans 中的所有内容都被视为插件。 GUI编辑器是一个插件,甚至文本编辑器也是一个插件。 这意味着 Netbeans 中真正分析 Java 代码并进行语法突出显示的任何部分也是一个插件(因为 Java 只是 Netbeans 突出显示的众多语言之一,所以这是一个插件是有道理的)。

我认为 fromvega 的建议是正确的。 创建清单文件编辑插件的教程为我指明了正确的方向。 本教程回避了用作字体/颜色预览的示例文档的文件。 它告诉您如何在这个新插件项目中创建一个。 (位于“在 NetBeans 系统文件系统中注册选项”,第 4 部分。大约占页面下方的 4/5。)

我的下一个想法是寻找 Java 语法编辑模式插件并找到此文件并更新它具有更丰富的示例文件。 我查看了安装目录,结果是空的,但我在用户设置目录中找到了看起来像适当的文件。 我的用户目录中有一个 config 目录,其中包含许多子文件夹(Windows:C:\Documents and Settings\saterus.netbeans\config)。

我在这个目录中进行了一些探索,但只找到了清单教程中提到的 xml 文件。 我一直无法找到我认为应该存在的 Java 插件的无扩展名示例文件。

由于我暂时碰壁了,我想我应该把它扔回 SO 社区,看看你们是否可以进行最后的飞跃并找到解决方案。

Within the Netbeans 6.5's Tools -> Options -> Fonts & Colors -> Syntax dialog, you have the ability to change the look and feel of the Netbeans text editor. When you select a language, you are presented with a preview of your font/color scheme. However, when I preview Java, there are far more options for syntax changes than are being displayed in that preview window. If I were able to view a more robust piece of code, I'd be able to see the immediate effect of more of the options.

How can I supply a preview document to view my font/color changes?

UPDATE:

After looking into this some more, I've been able to narrow down the problem a bit. From what I can tell, everything in Netbeans is considered a plugin. The GUI editor is a plugin, and even the text editor is a plugin. This means that what ever piece of Netbeans that actually analyzes Java code and does syntax highlights is also a plugin (since Java is just one of many languages Netbeans highlights, it makes sense this is a plugin).

I think fromvega is on the right track with his suggestion. The tutorial for creating a manifest file editing plugin pointed me in the right direction. The tutorial eludes to a file used as a sample document used for font/color previews. It tells you how to create one inside this new plugin project. (Located in "Registering the Options in the NetBeans System Filesystem", part 4. About 4/5 of the way down the page.)

My next line of thought was to look for the Java syntax editing mode plugin and find this file and update it with a richer example file. I looked in the installation directory and came up empty, but I found what looks like the appropriate files within my user settings directory. There is a config directory with a lot of subfolders within my user directory (Windows: C:\Documents and Settings\saterus.netbeans\config).

I've been poking around inside this directory a bit, but have only found the xml files the manifest tutorial talks about. I have been unable to find the extensionless sample file for the Java plugin that I believe should be there.

Since I've hit a brick wall for the moment, I thought I'd toss it back to the SO community and see if you guys might make the last leap and find the solution.

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

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

发布评论

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

评论(3

兮子 2024-07-16 21:30:12

对于那些想要自己更改此文件的人来说,可以在 unix 计算机上使用 grep 来查找文件,即

grep -lr "some part of the current sample code" /path/to/netbeans

我使用此方法来查找 ruby​​ 示例文件名,并从中确定它保存在 org-netbeans-modules-ruby 中.jar 作为名为 RubyExample 的文件。 通过简单地更改该文件,我能够构建一个更好的示例文件供我自己使用。

希望这对某人有帮助!

Just for anyone who wants to alter this themselves it is possible on a unix machine to use grep to locate the file i.e.

grep -lr "some part of the current sample code" /path/to/netbeans

I used this method to locate the ruby example filename and from that identified that it is kept in org-netbeans-modules-ruby.jar as a file called RubyExample. By simply altering that file I was able to construct a better sample file for my own use.

Hope this helps someone!

空气里的味道 2024-07-16 21:30:12

显示的文档(针对每种 mime 类型)在“系统文件系统”的特定文件夹中指定(这是一个 NetBeans 概念,它是由各个模块的贡献组成的虚拟文件系统;这就是动态注册功能的方式在 NetBeans 中)。

模块通常在插件中名为“layer.xml”的文件中指定其系统文件系统贡献。 创建插件模板通常会为您创建此插件。

例如,Python 示例的注册方式如下:

<filesystem>
    ...
    <folder name="OptionsDialog">
        <folder name="PreviewExamples">
            <folder name="text">
                <file name="x-python" url="PythonExample.py"/>
            </folder>
        </folder>
        ...

这里,PythonExample.py 是与图层文件位于同一目录中的示例文件。

因此,您需要做的是创建一个插件,覆盖您关心的 mime 类型的现有注册,并提供备用示例文档。 您可能需要先隐藏现有注册(请参阅 _hidden
部分来自 http://doc.javanb.com/netbeans-api-javadoc-5-0-0/org-openide-filesystems/org/openide/filesystems/MultiFileSystem.html)。

希望这能引导您走向正确的方向。

然而,考虑一下,我们可能应该使预览区域可编辑 - 这样人们就可以剪切和编辑预览区域。 将他们关心的任何代码片段粘贴到那里。 这不会是持久的,因此每当您更改语言时,您都会恢复原始示例 - 但它提供了一种查看您自己的代码的快速方法。 这不应该仅仅适用于字体和字体。 颜色自定义,但也适用于格式预览面板。

我已为此向 NetBeans 提出问题:
http://www.netbeans.org/issues/show_bug.cgi?id=155964

-- Tor

The document which is displayed (for each mime type) is specified in a particular folder in the "system file system" (which is a NetBeans concept which is a virtual file system composed from contributions from individual modules; this is how functionality is dynamically registered in NetBeans).

Modules typically specify their system file system contributions in a file named "layer.xml" in the plugin. The create plugin templates typically offer to create this for you.

For example, here's how the Python example is registered:

<filesystem>
    ...
    <folder name="OptionsDialog">
        <folder name="PreviewExamples">
            <folder name="text">
                <file name="x-python" url="PythonExample.py"/>
            </folder>
        </folder>
        ...

Here, PythonExample.py is a sample file in the same directory as the layer file.

Therefore, what you need to do is create a plugin which overrides the existing registration(s) for the mime type(s) you care about and provide alternate sample documents. You may need to hide the existing registration first (see the _hidden
part from http://doc.javanb.com/netbeans-api-javadoc-5-0-0/org-openide-filesystems/org/openide/filesystems/MultiFileSystem.html ).

Hopefully this guides you in the right direction.

However, in thinking about it, we probably ought to make the preview area editable - so people can cut & paste whatever codefragment they care about right in there. This wouldn't be persistent, so whenever you change languages you get the original samples back - but it provides a quick way to see your own code. This shouldn't be just for the Fonts & Colors customization, but for the Formatting preview panels as well.

I've filed an issue against NetBeans for this:
http://www.netbeans.org/issues/show_bug.cgi?id=155964

-- Tor

爱格式化 2024-07-16 21:30:12

我认为你只能使用新插件来实现这一点,因为你需要某种解析来定义什么是什么。

看看这些教程,我没有详细阅读它们,但它们似乎向您展示了如何做您想做的事情:

http://platform.netbeans.org/tutorials/nbm-mfsyntax.html
http://www.antonioshome.net/kitchen/netbeans/nbms-coloring。 php

I think you can only accomplish that with a new plugin, since you need somekind of parsing to define what is what.

Give a look a these tutorials, I haven't read them in details but they seem to show you how to do what you want:

http://platform.netbeans.org/tutorials/nbm-mfsyntax.html
http://www.antonioshome.net/kitchen/netbeans/nbms-coloring.php

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