syntax highlighting Syndicate content

warning: Creating default object from empty value in /www/htdocs/w0065fc9/milianw/modules/taxonomy/taxonomy.pages.inc on line 33.

» Git commit message highlighting in nano

Sat, 11/24/2012 - 16:07

For those who use nano as their CLI editor of choice: Here’s a syntax highlighting file for Git commit messages which also supports the special KDE commit hook keywords.

  1. ## syntax highlighting for git commit messages of KDE projects
  2. syntax "patch" ".git/COMMIT_EDITMSG$"
  3.  
  4. # overlong lines
  5. color brightred "^.{70,}.+$"
  6.  
  7. # KDE commit hook keywords, see: http://community.kde.org/Sysadmin/GitKdeOrgManual#Commit_hook_keywords
  8. color yellow "^(FEATURE|BUG|CCBUG|FIXED-IN|CCMAIL|REVIEW|GUI|DIGEST):.*$"
  9. color yellow "(SVN_SILENT|GIT_SILENT|SVN_MERGE)"
  10.  
  11. # comment
  12. color blue "^#.*$"
  13.  
  14. # special comment lines
  15. color green "^# Changes to be committed:"
  16. color red "^# Changes not staged for commit:"
  17. color brightblue "^# Untracked files:"
  18. color brightblue "^# On branch .+$"
  19. color brightblue "^# Your branch is ahead of .+$"
  20.  
  21. # diff files
  22. # meh - cannot match against \t ... should be: ^#\t.*$
  23. color cyan "^#[^ a-zA-Z0-9][^ ].*$"

Just put this file as gitcommit.nanorc or similar somewhere on your disk and load it from your .nanorc or even /etc/nanorc like this:

  1. include "/path/to/gitcommit.nanorc"
Screenshot of highlighted git commit message
Screenshot of highlighted git commit message

» Highlighted Backtraces on BKO

Mon, 09/20/2010 - 19:05

Hello everyone, the “I can syntax highlight everything” guy speaking again :)

Yeah, I couldn’t sleep well after I put colors on Dr Konqi. I also did the same for Kate, if you did not notice it. There is a new GDB Backtrace syntax highlighting file for it, giving you the same pleasant experience you are now used to from Dr Konqi. Awesome.

But well, lets admit it: What use are these two for bug triaging? Visit any crash report on bko and you are left to plain old black-on-white… Stone-age stuff, lets put it on LSD, shall we not? I propose: The GDB Backtrace highlighter GreaseMonkey userscript!

Bug reports, feedback, pizza & beer all welcome :)

PS: How is GreaseMonkey for Konqueror coming along, anyone working on that? Does someone know whether Chrome or Opera could be made to work with this?

PPS: We could also install this script directly on BKO, but I fear it might be a tad bit slow, esp. for huge backtraces.

PPPS: Attached backtraces should be setup to be opened in Kate :)

» 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 namespace and a following line starts with class or struct (C++ mode only)
  • don’t add brace when current line contains class, interface or struct and the following line contains private, public, protected. C++ code is also checked for signals, Q_SIGNALS", other modes are checked forfunction`.

This should fix the bug for code like (note the indendation levels):

  1. namespace foo { // insert line here
  2. class bar;
  3. }
  4. class asdf { // insert line here
  5. private:
  6. ...
  7. };

» 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.php by 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:

  1. ## syntax highlighting for /etc/apt/sources.list
  2.  
  3. syntax "apt/sources.list" "sources\.list(\.old|~)?$"
  4. # component
  5. color brightmagenta "^deb(-src)? ((http|file|ftp):/[^ ]+|cdrom:\[[^\]]+\]/|cdrom:\[[a-zA-Z0-9\._-\(\) ]+\]/) [^ ]+ .+$"
  6. # distribution
  7. color brightred "^deb(-src)? ((http|file|ftp):/[^ ]+|cdrom:\[[^\]]+\]/|cdrom:\[[a-zA-Z0-9\._-\(\) ]+\]/) [^ ]+"
  8. # URI
  9. color brightgreen "(http|file|ftp):/[^ ]+"
  10. # cdroms
  11. # [^\]] does not work…
  12. color brightgreen "cdrom:\[[a-zA-Z0-9\._-\(\) ]+\]/"
  13. # deb / deb-src
  14. color cyan "^deb"
  15. color brightblue "^deb-src"
  16. # comments
  17. 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.

  1. # ini highlighting
  2. syntax "ini" "\.ini(\.old|~)?$"
  3.  
  4. # values
  5. color brightred "=.*$"
  6. # equal sign
  7. color green "="
  8. # numbers
  9. color brightblue "-?[0-9\.]+\s*($|;)"
  10. # ON/OFF
  11. color brightmagenta "ON|OFF|On|Off|on|off\s*($|;)"
  12. # sections
  13. color brightcyan "^\s*\[.*\]"
  14. # keys
  15. color cyan "^\s*[a-zA-Z0-9_\.]+"
  16. # comments
  17. color brightyellow ";.*$"