Name: Cursor Hook
Hook Pointer Block Address: 9B7C
Hook Enable BCALL: 4F60
Hook Disable BCALL: 4F69
Hook Call BCALL: 4F57
Hook Active Flag: 7, (iy + 34h)
This hook is called when the edit cursor (the flashing block cursor) is shown or hidden.
Using the Hook
There are three events that are passed for various events, identified when A = 22h, 23h, or 24h. I'm not aware of any event where A < 22h.
- A = 22h: This is one of the two events that occur before the cursor will be displayed. Returning with the zero flag set will abort the display sequence, but returning with the zero flag reset will cause the sequence to continue. If you want to change the cursor, draw your own one here and return with the zero flag set.
- A = 23h: I (JasonM) have no clue why this event exists! It is called after event 22h, but before the actual drawing occurs. It's only called if you returned with the zero flag reset for event 22h (basically, if you said you want the cursor to flash.) If you return with zero set, it cancels the flash, otherwise it will draw it's usual cursor. It would appear that the TI-OS just wants to confirm your decision from the first event!
- If event 22h is returned with Z set (i.e. cancel normal cursor), then this event will trigger only if the cursor is showing and a key is pressed (the ability to check which key is inconclusive, although BC seems to be preserved from event 22h). Here would be a good time to erase an old custom cursor and draw the new one. Return with Z set in this case to cancel the normal action (Z reset will draw the normal large-font cursor).
- (thepenguin77) This is indeed called when a key is pressed while the cursor is showing. I believe the idea here is that you can update the cursor on the chance that it changed (like 2nd, Alpha, or Ins). Treat this as event 22h so that the cursor will be immediately updated to reflect the shift key. (Otherwise it waits until the next flash).
- A = 24h: This event is called when the cursor block is about to be replaced with the character underneath it. Returning with the zero flag set will cause this operation to be canceled (the cursor block will be left on the screen.) The character underneath the cursor is passed in B (it's simply a copy of curUnder), and you should return the character in A. If you want to, you can return any character you like: this will make it appear that the cursor is above a character other than it actually is (note: this doesn't actually edit the text in the edit buffer.) The TI-OS tends to cause redraw errors if you return a character other than in B, so it's probably a good idea to to just return B (make sure you do an "or a" to clear the zero flag, or the cursor won't disappear.)
Since it will be fired when the user enters most contexts (any context that starts in an edit buffer), it can serve as a useful hook if you want to fire in a particular context after the context is set up. It could also serve as a replacement for a custom interrupt under some situtations.
Credits and Contributions
- Michael Vincent: Example of hook usage in Omnicalc