My first Android app: n Tile Puzzle

So I released my first Android app. Nothing special, just a version of the same type of sliding puzzle that’s already all over the Google Play™ store. It started out as a little project I had no intention of actually publishing, but once it was finished it seemed a good test project to have a first look at how the Google Play system works, so there it is.

Get it on Google Play™

The full source code is available under the GNU GPL on the project page. Entirely undocumented, but most of it should be simple enough.

Google Play is a trademark of Google Inc.

c2de57dda91b5c3493ef8122983d8847
Share via email
Posted in Android | Tagged , | Leave a comment

New Grep Console release: 3.4

After the previous Grep Console releases, I’ve received a lot of comments and suggestions. Version 3.4 incorporates these new features and is now ready for download.

Features:

  • Quick expressions – Expression items may now have a quick expression which is tested before the main expression is evaluated.
  • Base paths for file links – A base path for relative file links can now be specified. By default, the project’s root directory is used. Suggested by Angel Ezquerra.
  • http:// prefix for URL links – URLs without a schema prefix can now be used in URL links. They will automatically be prefixed with “http://”. Suggested by Angel Ezquerra.
  • Offsets for file and Java links – For file and Java links, an optional character offset can be specified to position the cursor at a specific column in the editor. Suggested by Peter Štibraný.
  • Eclipse variables in link pattern fields – Pattern strings in link configurations can reference use Eclipse variables (as used in the arguments tab of the launch configuration dialogue). Suggested by Angel Ezquerra.
  • Custom names for expression groups – Groups of expression items can now be assigned custom names. These names can be used in link pattern strings. Suggested by Angel Ezquerra.
  • Configurable colours in the Grep View – By default, the Grep View now uses the same colours as the Eclipse console. These colours can be changed in the preferences. Suggested by Angel Ezquerra.
  • Configurable link modifier key – On Mac systems, the link modifier key is now Command instead of Ctrl. The modifier key can be changed in the preferences. Suggested by Peter Štibraný.

Bug fixes:

  • Null pointer exception when clicking on style assignment for a rewrite group

Special thanks go to everyone who has been sending me feedback and ideas, especially Angel Ezquerra, who has provided the ideas for many of the new features added to recent releases.

For installation instructions, please see here. As always, feedback is welcome.

d0151d39dc6fd1aae1640a1e7fbdbac4
Share via email
Posted in Grep Console | Tagged , | Leave a comment

Bugfix Release: Grep Console 3.3.1

Version 3.3.1 of Grep Console is out, fixing a bug which prevented links assigned to whole lines from working. Thanks to Angel Ezquerra for reporting this bug. CTRL key handling for links was also improved.

For installation instructions, please see here. As always, feedback is welcome.

e65a75042419cdd9bc76a0c5d8deaa8a
Share via email
Posted in Grep Console | Tagged , | Leave a comment

Grep Console How-to #7: Rewriting Lines

As of Grep Console 3.3, lines filtered to the Grep View can be rewritten. For example, information from your log4j output that’s irrelevant during development could be removed. Or if you put some keywords in your debug output solely to have something for Grep Console to recognise, you could strip that from your Grep View output. These rewritten lines are not subject to the standard styles applied by Grep Console via regular expression matching. Instead, you can specify the styles for your rewritten lines directly.

Simple rewriting

Let’s say you have log4j prefix your error messages with the string [ERROR]. You want to filter those lines to Grep View, and you want to highlight them with a red background. But since you’re highlighting them, there’s no reason to keep the [ERROR] tag, so you want to filter that out.

This is easily done. We’ll start with an expression that matches your error lines:

\Q[ERROR] \E(.*)

This captures strings starting with the [ERROR] tag followed by a space and any number of additional characters. These additional characters are also marked as a capture group, because we still need them for our rewritten line.

Now we can add a rewrite expression. In this case, it’s simple – we only want to output the content of our capture group, so the rewrite expression looks like this:

{1}

After entering the rewrite expression, the style/link table will show an additional line labelled Whole rewritten line, which we can use to assign a red background to our rewritten line:

Simple rewriting settings

And here’s some sample output, with the regular console on the left and the Grep View output on the right:

Simple rewriting result

Styles and links

We don’t have to base the visible content of our rewritten line on the original console output. For example, if our application writes lots of very long HTTP links to the console, we actually might decide to not display the URLs, and instead just show a short text with a highlight and a clickable link that opens the URL in a browser.

A regular expression for this scenario might look like this:

(\Qhttp://\E\S*)

This matches strings starting with the prefix http:// followed by any number of non-whitespace characters. This whole URL is marked as a capture group.

We’ll replace the entire line with a simple string via the following rewrite expression:

Click (here)

Note that we’ve marked the word “here” as a group in the expression. This adds yet another line to the style/link view, labelled Rewritten group 1:

Links settings

We can use this group to assign a highlight style to the word “here”. And we’ll add a link of type URL, using {1} as the link’s URL. This will use capture group from the regular expression as the link target – and that capture group contains exactly the HTTP link from the original line.

This is what our rewritten line looks like when holding the CTRL key and hovering the mouse cursor over the link:

Links result

 

37a6424f28c8f23af02a81813932cf58
Share via email
Posted in Grep Console | Tagged , | Leave a comment

Grep Console How-to #6: Autostart Links

Grep Console 3.2 introduced links which can be clicked to perform specific actions, like opening an Eclipse editor or a web browser (see the previous how to for an introduction to links).

Expanding on this concept, Grep Console 3.3 adds autostart links. An autostart link is not clickable. It’s not even displayed. Instead, the link’s action is simply executed whenever a line matching its expression is written to the console.

Configuration

In the expression dialogue, an autostart link can be configured on the left side, below the preview panel:

An autostart link can be configured on the left side, below the preview panel.

Of course, the same link can also be set on a capture group or the whole line if you also want it to be able for manual clicking.

Autostart links are a feature of Grep View filtering and only work if the expression is enabled for filtering.

Example

Say I have a JUnit test case which starts an HTTP server and does some testing on it before shutting down the server again. Sometimes I want to have an actual look on the server before the test’s clean up code is executed. So I’ll log the address of my server to the console and set a breakpoint before the clean up part.

If my log output looks like this…

Server URL: http://localhost:8080/my/test/page

…I can set up a regular expression like this…

\QServer URL: \E(http\:\/\/\S+)

…to capture (and perhaps highlight) the line.

I can then configure an autostart link of type URL for this expression and use {1} as the URL to automatically open the capture URL whenever my test case outputs this line.

2b84effec820aaea0693e8768791a246
Share via email
Posted in Grep Console | Tagged , | Leave a comment

New Grep Console release: 3.3

Hot on the heels of last week’s 3.2.1 release, Grep Console 3.3 is out, providing new features and several bug fixes.

Features:

  • Original line styles may now be kept even if custom styles are applied to a line.
  • All dialogues now feature help links. Thanks to Angel Ezquerra for suggesting this feature.
  • Autostart links – Each expression can specify a link which is executed automatically when a matching line is written. Requires the Grep View to work.
  • Grep View line rewriting – Lines filtered to the Grep View can now be rewritten. Rewritten lines can include any parts of the original line and may have different styles and links than the original console output. Thanks to Didier Grzejszczak for suggesting this feature.

Bug fixes:

  • Grep View pattern matching – completely broken in the previous release. Thanks to Matthias Scholz for reporting this bug.
  • Fixed NullPointerException for matches with unused groups. Thanks to Christian Afonso for reporting this bug.
  • Settings are now saved correctly when the Grep Console dialogue is opened from the CDT build console. Thanks to Angel Ezquerra for reporting this bug.

For installation instructions, please see here. As always, feedback is welcome.

aea7f7f00259f9dfb205a9d85cd5b166
Share via email
Posted in Grep Console | Tagged , | Leave a comment

Bugfix Release: Grep Console 3.2.1

Version 3.2.1 of Grep Console is out, fixing the following bugs:

Performance issues with regular expression matching. Changes in the matching code lead to serious performance problems for some users. Some modifications in the matching function should hopefully fix that. Thanks to Michaël Clavier and “Jordi” for reporting this bug.

Unmatched lines are no longer set to the default style. Previously, lines that did not match any expressions were nevertheless set to the default font style, overriding font colours set in the console preferences. Thanks to Angel Ezquerra for reporting this bug.

a62be3c8a0a2f78f5038a6b18c8d8b39
Share via email
Posted in Grep Console | Tagged , | Leave a comment

Grep Console How-to #5: Links

One feature I had been considering for Grep Console for a while was customisable links in the matched text lines. For example, HTTP hyperlinks could be rendered as links and open the browser when clicked. I abandoned the idea when I couldn’t figure out how to put links in the console and didn’t want to hold up the original release of version 3 even longer. Recently I got an email requesting a feature just like this, so I delved a little deeper into the Eclipse APIs, and the result is the newly release version 3.2 with link support.

Basics

Links, like styles, can be assigned to whole lines or capture groups. This is done in the style assignment table in the expression dialog, which now features a column for the links:

Edit expression dialog Double clicking a cell in the link column will open a dialogue that can be used to edit the link for the corresponding group. The dialogue shows a combo box allowing you to select between “no link” and various types of links – see below for details. The rest of the dialogue content changes depending on the selected link type:

Edit link dialog

Also, right clicking on a link cell in the style/link assignment table lets you copy and paste links.

Patterns

Links don’t make a lot of sense if they are static and always link to the same target regardless of the text they have been matched to, so most fields for the various types of links are so-called patterns which allow you to use parameters to insert portions of the matched text.

As an example, an expression that matches strings starting with “www” could use a link of type URL wih the following URL pattern parameter to open the corresponding website:

http://{match}

The following parameters are available in patterns:

{line} – The whole line text string of the matched line.
{match} – The whole matched text.
{group} – The text of the matched capture group.
{1}, {2},… – The text of the specified capture group.

Using links

In order to not interfere with normal cursor positioning in the console, Grep Console don’t automatically react when clicked on. They also don’t have a specific style of their own – each link is assigned to a group in its expression, so the same group can be assigned any style you like to highlight the link. To actually “open” a link, i.e. to execute the behaviour associated with it, hold down the CTRL key and click on the link. Hovering over a link with CTRL held down will turn the mouse cursor into a link cursor and show a tooltip for the link.

File links

A file link points to a file in the file system and opens it in an Eclipse editor when the link is clicked. An optional line number parameter can be used to position the cursor in a specific line.

For example, the following expression can be used to find text file references with line numbers like “/home/myuser/myfile.txt:42″ in the console:

(\S+\.txt)\:(\d+)

The first group matches a string of non-whitespace characters ending with “.txt” directly before a colon, while the second group matches a series of digits directly after the same colon.

File link

For this expression, a file link can be configured to use {1} (the first capture group) as the file name and {2} (the second capture group) as the line number.

Java type links

Similar to file links, Java type links open any type from a Java project in an Eclipse editor. The types must be referenced by their fully qualified name and be in the same project that is associated with the launch configuration connected to the console.

If the classes in your project belong to the namespace com.myproject, the following expression can be used to find references like “com.myproject.MyClass:42″ in the console output:

(com\.myproject\.\S+)\:(\d+)

Java type link

Like the example in the file link section, the first group captures the fully qualified class name, while the second group captures the line number. Use {1} for the Java type and {2} for the line number field in the link settings.

URL links

Links can be opened internally in an Eclipse browser, or externally in whatever application the operating system deems appropriate for the link. Usually this will be the system browser, but depending on the prefix and file extension, any kind of application (e.g. an FTP client or an image editor) may be associated with a link.

The following expression will match all links starting with “http://”:

(http\:\/\/\S+)

URL link

With this expression in place, a URL link with {match} as its URL pattern can be configured. Use the checkbox below the URL field to specify whether the link should be opened internally or externally.

Command links

If opening files and URLs is not enough for you, you can use command links to call system or shell commands. For example, to open image files with the image viewer Gwenview, you can use the following expression to capture all PNG file names in the console:

(\S+\.png)

Then a command link with the following command pattern will open the viewer when the link is clicked:

gwenview {match}

Command link

For commands where the working directory matters, you can control it with a separate field. If the working directory is not specified, Eclipse’s own current working directory is used.

Script links

With this link type, you can execute scripts directly in your Eclipse environment. The scripts are executed via the Java Scripting API and can be written in any language installed for the Java Scripting API in your Eclipse setup. Out of the box, the API supports Javascript.

A drop down box in the link dialog allows you to pick one of the available languages. This list is queried from the Scripting API, and since some language modules offer several alternative names for the language they support, the drop down list may include multiple entries for the same language. For example, “Javascript” will also show up as “js”, “rhino”, “javascript”, “ECMAScript” and “ecmascript”.

The code box lets you enter script code in the selected language. The script code doesn’t use pattern parameters, but the script can access the expression match information in a number of variables passed to it upon execution. These variables are listed a tooltip text which appears if you leave the mouse cursor hovering over the code box for a few seconds.

Scripts executed via the Java Scripting API have full access to the entire Java API and all libraries in the class path (see below). Here, I only provide a simple example that prints the matched line of text to stdout:

importPackage(java.lang);
java.lang.System.out.println(wholeLine);

Script linkA note on the class path: In Eclipse, each plug-in has its own class loader, and therefore its own class path. Scripts run from Grep Console therefore have access to all the classes that the Grep Console plug-in itself  has access to. Classes from other, unrelated plug-ins are not accessible, and neither are the classes from your project producing the console output.

f13f024c75502abb18fa2efa2ec34df7
Share via email
Posted in Grep Console | Tagged , | Leave a comment

New Grep Console release: 3.2

A new version of Grep Console is out, with new features and a bug fix.

Edit link dialog

Features:

  • Multiple matches per line – Expressions may now match multiple substrings per line. Previously, only the last match in a line was recognised. Thanks to Tiogshi Laj for suggesting this feature.
  • Links – Expressions and capture groups may now be assigned links. These links will be executed when the matched substring is clicked on while the CTRL key is pressed. Different link types can be used to open text files or Java types in the Eclipse editor, open URLs in a browser or execute scripts and system commands. Thanks to Angel Ezquerra for suggesting this feature.
  • Pattern help – The expression dialog now contains a web link to the Java Pattern API documentation (explaining the regular expression syntax).

Bug fixes:

  • Configuration XMLs were exported using a wrong encoding on Windows. Thanks to Tiogshi Laj for reporting this issue.

For installation instructions, please see here. As always, feedback is welcome.

472f587b8ff73c316b24908f228d2ba1
Share via email
Posted in Grep Console | Tagged , | 3 Comments

Fixed a link on my Eclipse update site

Just in case anyone has had trouble installing the 3.x version of Grep Console, I’ve fixed a link on the update site. Before the fix, the link on that page pointed to the old update site which, when entered in Eclipse, would only install the old 2.x version of Grep Console. The link is corrected now. If you’re stuck on version 2.x, or if the update site in your Eclipse is “eclipse.musgit.com” instead of “eclipse.schedenig.name”, please update to the correct link found here.

If you copied the update link site directly from the installation page, or if you used any of the download links there or in Eclipse Marketplace, you should have had the correct version all along. No need to do anything in this case.

Thanks to “Glen” for pointing out this error.

4fb15870399f2adbb80bb62d16e8d2d6
Share via email
Posted in Grep Console | Tagged , , | 1 Comment