Saturday, June 23, 2012

Interlude 2 - Codea Keyboard Buttons & Editing (Updated 10/1/16)

Webcomic Courtesy of Ethanol & Entropy

Interlude 2.1 Custom Buttons

The latest release of Codea (2.3.2) added the ability to search your code. A side effect of this is I discovered what another one of the Codea custom keyboard buttons did. Like most folks I had been using a fairly haphazard trial and error approach to working out what each one of the buttons did but this is tempered somewhat by the fear that I might push the armageddon button.

So for my benefit as much as anyone else I decided to list all of the custom keyboard buttons here and describe what they do. Note that some of these keys are context sensitive and some will pop up an action dialog box.

Figure 1

Going from left to right, the numbers below refer to the eleven custom buttons shown in Figure 1.
  1. Indent Code - This will indent the text to the right of the cursor four spaces. If you select a block of code then this key will indent the lines selected by four spaces.
  2. Undo - This will undo the last action.
  3. Codea Reference Documents (Figure 3) - This button will popup the Codea Reference Documents. Note that if you select a function using tap and hold, then one of the options in the subsequent cut, copy, and paste dialog will be lookup. Tapping this will open the same reference document dialog.
  4. Numeric Function Popup - As shown in Figure 2 this will popup a dialog from which you can choose to insert: square brackets, parenthesis, minus, plus, multiplication, division, modulas, hash, tilda, less than or greater than symbol at the cursor location.
  5. Cursor Left or Right - Tapping this button will move the cursor one space left or right, depending on which side of the button you tap. Using a finger it is sometimes difficult to  precisely locate the cursor, particularly in the middle of a word. This button can help with that.
  6. Select Text Left or Right - Similar to the previous key this one will move the cursor one position left or right depending on which side of the button you tap. In addition, it will also select the text as the cursor moves.
  7. Insert Brackets - This button will insert rounded brackets at the cursor location.
  8. Insert Quotes - Another obvious button, this one will insert quotes at the cursor location.
  9. Function Lookup and Search (Figure 4) - This button will provide you with a popup dialog with a list of functions in your program. Tapping on a function in the list will jump you to that position in your code. You can also search for a word in your code using the search bar. The search will only start after you type three characters.
  10. Equals - this is the same as the equals key. It is placed here as a convenience since you use it a lot.
  11. Run Program - this key operates the same as the arrow in the bottom right of the coding screen. It will attempt to compile and run your program.

Interlude 2.2 Editor Gestures

Thanks to Keebo for pointing out that there are also gestures available on the Editor Screen. 

If you swipe up or down on the Cursor Left/Right Key (the key numbered 6 in Figure 1), then the cursor will move up or down one line, in the direction of your swipe.

In addition, if you swipe left or right on the main screen this will move the cursor left or right one space.

Interlude 2.3 Undo

The undo function in Codea is a bit hard to find. If you press the ".?123" button on the default iPad keyboard this button will be shown in the bottom left corner.  

Interlude 2.4 The Split Keyboard

If you use the iPad keyboard a lot you may accidentally cause it to split to either side of the screen. This is a "feature" introduced in a recent version of iOS. Personally we don't like it. You can turn it off as an option in the Settings App. Go to Settings -> General -> Keyboard -> Split Keyboard. Thanks to dave1707 on the Codea Forums for the following explanation on how to use this feature.

"To turn the split keyboard on (assuming this option is enabled in Settings), hold your finger on the hide keyboard button (lower right), and a pop up will appear. This has 2 options, undock and split. If you press undock, the keyboard will move up to the middle of the screen. If you press split, the keyboard will split in half. 

If you press and hold the hide keyboard button while in those modes, you will get a popup that says, Dock and Merge. Pressing that, the keyboard will go back to normal size at the bottom of the screen. Also, with the keyboard in normal size, if you place your finger and thumb together on the middle of the keyboard and then move them apart towards the sides, the keyboard will split. Placing your thumb and finger spread apart on the keyboard and moving them together, the keyboard will close."

Figure 2

Figure 3

Figure 4