if achar = '.' then
technically, you should also test for aCommand = ecChar. Though aChar can not be '.' unless it is ecChar.
schema_tablename:=editor.GetWordAtRowCol(editor.CaretXY);
GetWordAtRowCol is locical. Use editor.LogicalCaretXY
After playing around with this it does seem that I will need a timer for when the user types the .
Any suggestions on how to implement that? Could I just use the standard system timer component?
Yes just the standard timer.
Make sure to cancel it on
- focus lost
- other keypress
- caret move (use Editor.OnStatusChange, it has a reason that can be inspected)
I have not tested your code, I do not know, if calling completion.execute BEFORE the editor handles the char may cause an issue.
There is
procedure RegisterCommandHandler(AHandlerProc: THookedCommandEvent;
AHandlerData: pointer; AFlags: THookedCommandFlags = [hcfPreExec, hcfPostExec]);
procedure UnregisterCommandHandler(AHandlerProc: THookedCommandEvent);
which allows to register a handler at different times during processing.
RegisterCommandHandler(@YourHandler, nil, [hcfFinish]);
will run AFTER SynEdit completely finished with the command
YourHandle must be
THookedCommandEvent = procedure(Sender: TObject; AfterProcessing: boolean;
var Handled: boolean; var Command: TSynEditorCommand;
var AChar: TUTF8Char;
Data: pointer; HandlerData: pointer) of object;