Mushrooms and Soy Sauce
When I was working for the electric light company in Hove, many years ago, the canteen ladies frequently served up, as part of a buffet, sliced raw mushrooms in soy sauce. Tasty side dish with a salad or buffet. Ingredients Thinly sliced mushrooms Dark soy sauce Method Thinly slice the mushrooms into a bowl Sprinkle over the soy sauce Leave for a while for the sauce to soak into and soften the mushrooms I have not seen this elsewhere or online, so I assume that the canteen ladies came up with the idea themselves.
Read more →Source Code Syntax Highlighting
One of the enhancements suggested for my android editor is syntax highlighting. The libraries I have found, including the one used in this blog, parse the input and produce output in HTML, using styled spans. Emacs makes extensive use of regular expressions for highlighting. HTML output is not very useful for a text editor. It could be used with Html.fromHtml() to produce styled text. This would then be loaded back into the editor all while the user is attempting to edit the text.
Read more →Musical Temperaments
My Tuner app uses equal temperament because that is the current standard and it is relatively easy to calculate using double precision arithmetic and maths library functions. First, declare some constants. private static final int OCTAVE = 12; private static final int EQUAL = 8; private static final int A_OFFSET = 9; private static final int C5_OFFSET = 57; The calculation first produces the cents relative to the reference, usually 440Hz.
Read more →Draw Musical Staff
A musical staff is not a trivial thing to draw because of the complex curves needed for the treble and bass clef. What is needed is a source of vector drawing coordinates. The data used was originally intended for use in postscript, so the vertical axis is reversed. // Treble clef private static final float tc[][]= { {-6, 16}, {-8, 13}, {-14, 19}, {-10, 35}, {2, 35}, {8, 37}, {21, 30}, {21, 17}, {21, 5}, {10, -1}, {0, -1}, {-12, -1}, {-23, 5}, {-23, 22}, {-23, 29}, {-22, 37}, {-7, 49}, {10, 61}, {10, 68}, {10, 73}, {10, 78}, {9, 82}, {7, 82}, {2, 78}, {-2, 68}, {-2, 62}, {-2, 25}, {10, 18}, {11, -8}, {11, -18}, {5, -23}, {-4, -23}, {-10, -23}, {-15, -18}, {-15, -13}, {-15, -8}, {-12, -4}, {-7, -4}, {3, -4}, {3, -20}, {-6, -17}, {-5, -23}, {9, -20}, {9, -9}, {7, 24}, {-5, 30}, {-5, 67}, {-5, 78}, {-2, 87}, {7, 91}, {13, 87}, {18, 80}, {17, 73}, {17, 62}, {10, 54}, {1, 45}, {-5, 38}, {-15, 33}, {-15, 19}, {-15, 7}, {-8, 1}, {0, 1}, {8, 1}, {15, 6}, {15, 14}, {15, 23}, {7, 26}, {2, 26}, {-5, 26}, {-9, 21}, {-6, 16} }; // Bass clef private static final float bc[][] = { {-2.
Read more →Expand Android Selection
When editing data or source files it would be useful to have selections triggered by a double tap or long press expand to enclosing delimiters or brackets. There is a section in the Android docs which explains how to set up your own context menu or contextual action mode, but not how to change the selection. This method is fine if you have only one text editor view in your app, but would be difficult with more than one as there is no way to identify the originating view.
Read more →