› syntax highlighting

» Dr Konqi now with colors (Updated)
Fri, 08/20/2010 - 18:19
Hey there :)
As I announced on the kde-core-devel mailing list, I planned to improve Dr Konqi for a long time, as for me as a developer it is an invaluable tool. Well, yesterday I sat down and implemented the first two things which I wanted for a long time:
Scroll to KCrash
Once the backtrace got loaded, Dr Konqi will automatically scroll to the line that contains [KCrash Handler]. No need to find that manually anymore. Awesome :)
Colors!
Yeah, you should know that I as a KDevelop user and developer am addicted to syntax highlighting. That’s what I did for Dr Konqi as well now:
So anyone using KDEBase trunk will now have a shiny Dr Konqi :) Feedback appreciated, esp. whether more or less should be highlighted. I personally found it overly colorful when I also highlighted pointer adresses (ignore the bug in that outdated screenshot). What do you think?
Anyhow, thanks to George Kiagiadakis for helping me find my way through Dr Konqi sources and accepting my feature additions.
Update
I put some more feedback into reality: Fixed width font, null pointers are bold and in addition common functions that lead to exits are now highlighted in red (i.e. qFatal, __assert_fail and abort):
» Kate Love: HighlightInterface, Autobrace
Sun, 11/22/2009 - 20:15
Well, I have to admit: I didn’t spent much time developing the PHP plugin for KDevelop these past weeks. Instead I hacked on Kate:
HighlightInterface
I added another Kate interface, this time to access some of the highlighting information:
- what’s the Attribute for a given default style right now? Default styles are those known from syntax files, e.g.
dsKeyword,dsFunction,… - what are used Attributes in a given line and what range do they occupy?
- what modes do we embed? E.g. PHP embeds HTML, JavaScript, CSS, …
- what mode is used at a given Cursor position?
This made it possible to port the “Export to HTML” action to a real plugin. If you come up with other output formats I might add them, I wondered about LaTeX support… might do this at some point.
This should also make it possible to use KatePart in other applications and than export the highlighting to a different format, e.g. a Flake shape for Koffice. Afaik this is actually planned by The_User - lets see if it works out!
The other stuff gives huge potential in various places, but I fear it won’t make it in KDE 4.4. But think of it:
- simple code completion based on keyword databases, dependent on the mode at the position where completion was requested
- same as above for snippets (actually this will make it to 4.4).
- insert your ideas here :)
Auto-Brace plugin
Jakob Petsovits created this gem of a plugin some time ago, yet it lived in playground was probably only used by few. I imported it to kdelibs, hence it will be shipped with KDE 4.4. It supersedes the limited “auto-brackets” feature of Kate and only adds braces when a newline gets added. I find this fits my personal coding habits much better than blindly copying brackets when they get added.
And I don’t just copied to kdelibs, I also added a few features:
- automatically add a semicolon after the closing brace when we start a new struct/class in C++ mode
- check for auto-brackets feature and disable it automatically
Also did this:
- don’t add brace when current line contains
namespaceand a following line starts withclassorstruct(C++ mode only) - don’t add brace when current line contains
class,interfaceorstructand the following line containsprivate,public,protected. C++ code is also checked forsignals,Q_SIGNALS", other modes are checked forfunction`.
This should fix the bug for code like (note the indendation levels):
namespace foo { // insert line here class bar; } class asdf { // insert line here private: ... };
» recent GeSHi contributions (apache, xorg, apt, performance, ...)
Wed, 06/18/2008 - 22:46
Your favourite syntax highlighter for web applications, GeSHi, recently got some new features and bug fixes. By yours sincerely. A rough summary of what I contributed:
- various performance improvements, i.e. some speed optimizations and reduced memory consumptions (especially peak memory usage is down by roughly 1MB when highlighting
geshi.phpby itself) - minor bugfixes, including one which prevents some nasty PHP notices on PHP 5 systems to contaminate your precious log files
- improved language files: bash, apache
- added language files: GNU Gettext, Xorg configuration and Apt
sources.list
Some of those features were already shipped with the recent 1.0.7.22 release. But the two new language files and the improvements to the existing apache language file are currently only available via SVN. Wait for the next stable release which should be 1.0.8.
To see two pretty examples, read on after the break:
» highlighted APT sources.list in nano
Tue, 04/10/2007 - 18:17
And here another syntax file for Nano. This time it highlights the /etc/apt/sources.list:
## syntax highlighting for /etc/apt/sources.list syntax "apt/sources.list" "sources\.list(\.old|~)?$" # component color brightmagenta "^deb(-src)? ((http|file|ftp):/[^ ]+|cdrom:\[[^\]]+\]/|cdrom:\[[a-zA-Z0-9\._-\(\) ]+\]/) [^ ]+ .+$" # distribution color brightred "^deb(-src)? ((http|file|ftp):/[^ ]+|cdrom:\[[^\]]+\]/|cdrom:\[[a-zA-Z0-9\._-\(\) ]+\]/) [^ ]+" # URI color brightgreen "(http|file|ftp):/[^ ]+" # cdroms # [^\]] does not work… color brightgreen "cdrom:\[[a-zA-Z0-9\._-\(\) ]+\]/" # deb / deb-src color cyan "^deb" color brightblue "^deb-src" # comments color brightyellow "#.*"
» Syntax Highlighting in Nano
Tue, 04/10/2007 - 17:14
When I’m messing around with config files on the command line my editor of choice is Nano. It’s simple, fast and pretty much straight forward. You don’t have to learn any commands and can use keyboard shortcuts just like in GUI programs.
Settings
Today I had a look on the project website and saw that there are tons of settings which I really missed before. Just have a look into your /etc/nanorc for a default config file with all settings and their default values. Here are those I like most:
- smooth (scrolling)
- autoindent
- mouse (though I use it rarely)
- smarthome
- tabsize (8 is far to much, I love 4)
Syntax Highlighting
Yes! Nano supports syntax highlighting! And I never knew it, but heck - it’s never to late. Not for neat features like this one, though I really wonder why this is not activated by default…
In the aforementioned /etc/nanorc are already some default languages which just wait to be commented out. You might also want to have a look into /usr/share/nano, there are some languages you can include in your nanorc file with:
include “/usr/share/nano/html.nanorc”
Additionally I found some more languages on the gentoo wiki. And of course I’ll post any homebrew syntax files in my Snippets section.
my syntax highlighting files
» syntax highlighting for *.ini files in nano
Tue, 04/10/2007 - 17:01
Use the snippet below in your ~/.nanorc or /etc/nanorc file to highlight *.ini files like php.ini in Nano.
# ini highlighting syntax "ini" "\.ini(\.old|~)?$" # values color brightred "=.*$" # equal sign color green "=" # numbers color brightblue "-?[0-9\.]+\s*($|;)" # ON/OFF color brightmagenta "ON|OFF|On|Off|on|off\s*($|;)" # sections color brightcyan "^\s*\[.*\]" # keys color cyan "^\s*[a-zA-Z0-9_\.]+" # comments color brightyellow ";.*$"