C/C++ 中的 ASCII 艺术注释头文件和代码文件
我饶有兴趣地观看了 Mojang "Mojam" for Humble Bundle(链接可能长时间无效) ,在整个视频中,我看到了一些关于这些人如何使用他们的代码的精彩内容。
其中之一是,一位开发人员在他的代码中使用 ascii 艺术注释来更好地导航。
这给出了这样的东西:
/////////////////////////////////////////////
// ___ ___ ___ _ __ _ //
// / |/ | / | | | | \ | | //
// / /| /| | / /| | | | | \| | //
// / / |__/ | | / / | | | | | |\ | //
// / / | | / / | | | | | | \ | //
// /_/ |_| /_/ |_| |_| |_| \_| //
// //
/////////////////////////////////////////////
int main()
{
// do some stuff
return 0;
}
这可能看起来很糟糕,但是与像 Sublime 这样的编辑器相关联,它变得强大,因为 Sublime 提供的“缩小”视图让您可以轻而易举地阅读该文本并在代码中导航。
现在,有很多很酷的 ascii 艺术文本生成器。 但这些(至少我看过的)都没有生成符合 C++/C 的文本。
含义:我必须在周围手动添加注释斜杠 (//
),以使其在代码中保持一致。
你们会用这个技巧吗?
如果是,您是否有工具可以在文本周围生成这些“评论”?
I watched with great interest the Mojang "Mojam" for Humble Bundle (link might not be valid for a long time), and throughout the video, I saw some great things on how these guys use their code.
One of these things was that one of the developer use ascii art comments in his code to better navigate around.
This gives something like this:
/////////////////////////////////////////////
// ___ ___ ___ _ __ _ //
// / |/ | / | | | | \ | | //
// / /| /| | / /| | | | | \| | //
// / / |__/ | | / / | | | | | |\ | //
// / / | | / / | | | | | | \ | //
// /_/ |_| /_/ |_| |_| |_| \_| //
// //
/////////////////////////////////////////////
int main()
{
// do some stuff
return 0;
}
This may look bad right there, but associated with editors like Sublime, it becomes powerful, because the "zoomed out" view that Sublime exposes lets you read that text and navigate in your code like a breeze.
Now, there are plenty of cool ascii art text generators out there.
But none of these (at least those I looked at) generate C++/C compliant text.
Meaning: I have to manually add the comment slashes (//
) all around to make it go along in the code.
Do you guys use this trick?
If yes, do you have a tool to generate these "comments" around the text?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
最近,当我在 .php 文件中搜索包含站点路由列表的内容时,我决定做出如此大的 ASCII 注释。现在,我使用它们(不是在所有源文件中,而是在长配置文件中),这些注释确实有助于导航。
这是它在我的 Sublime Minimap 中的样子:
到目前为止,我没有不要自动化创建此类评论的过程。我使用此网站的在线 ASCII 创建器。我使用“基本”字体
Recently, when I was searching something in my .php file with list of routes for a site, I've decided to make such big ASCII comments. And now, I use them (not in all source files, but for example in long config files), and these comments really help to navigate.
Here is how it looks in my Sublime Minimap:
So far, I didn't automate the process of creating such comments. I use online ASCII creator from this site. I use font "basic"
是的,我用来添加这些类型的“导航”提示。特别是在通信部分,它有许多相似的部分,但处理不同的消息类型。
我在 Mac 上工作,所以这是我的设置。
以前我使用过仪表板小部件
http://memention.com/figlet/
但我最新的事情是使用 Automator 创建一个服务并安装 < code>figlet 与自制程序。然后在服务中我有这个单行(也单击“输出替换选定的文本”)
现在在任何应用程序中我只需右键单击一些文本就可以拥有Figlet。
我喜欢的字体是
smslant
然后我通常只是在后面添加
/*
和*/
。编辑
好吧,我刚刚更新了我的服务以添加 C 评论
Yes I use to add those kinds of "nav" cues. Specially in communication parts which has many similar parts but handle i.e. different message types.
I work on a Mac so here goes my setup.
Previously I used a dashboard widget
http://memention.com/figlet/
But my latest thing is to create a Service with Automator and install
figlet
with homebrew. Then in the Service I have this one-liner (also clicked "Output replaces selected text")Now in any App I can have figlets just by right-clicking some text.
My preferred font is
smslant
Then I usually just add
/*
and*/
after.Edit
Well, I just updated my Service to add that C comment
不。我不使用这样的东西,并且会发现这样的东西比无用更糟糕。屏幕=带宽。像这样浪费空间会降低代码的可读性。
:-)
NO. I don't use such things and would find such things worse than useless. Screen = bandwidth. Wasting space like this decreases code readability.
:-)
如果您使用 SublimeText,我建议尝试 ASCII Decorator。它很容易安装,除了 Sublime 之外不需要任何其他东西,并且它适用于每个操作系统。
另外,它还有很多漂亮的字体!
If you're using SublimeText, I suggest to try ASCII Decorator. It's easy to install it, it doesn't require anything else than Sublime and it works on every OS.
Plus, it has a lot of nice fonts!
尝试使用支持#pragma 标记的 IDE?
http://cocoasamurai.blogspot.co .uk/2006/09/tip-pragma-mark-organizing-your-source.html
try an IDE that supports #pragma mark?
http://cocoasamurai.blogspot.co.uk/2006/09/tip-pragma-mark-organizing-your-source.html