I looked in the help file but could not find anything.
I would like my editor program to display the line number and column in real time.

If you meant the PB help, don't look any further. PB does not support 'advanced' things like that, you have to use the OS API's directly on all platforms.spacebuddy wrote:I looked in the help file but could not find anything.
Code: Select all
EnableExplicit
ImportC ""
sel_registerName(MethodName.S)
class_addMethod(Class.I, Selector.I, Implementation.I, Types.S)
EndImport
ProcedureC SelectionDidChangeCallback(Object.I, Selector.I, Notification.I)
Protected Range.NSRange
CocoaMessage(@Range, GadgetID(0), "selectedRange")
StatusBarText(0, 0, "Cursor position: " + Str(Range\location),
#PB_StatusBar_Center)
EndProcedure
Define AppDelegate.I = CocoaMessage(0, CocoaMessage(0, 0,
"NSApplication sharedApplication"), "delegate")
Define DelegateClass.I = CocoaMessage(0, AppDelegate, "class")
Define Range.NSRange
Define Selector.I = sel_registerName("textViewDidChangeSelection:")
OpenWindow(0, 270, 100, 180, 100, "EditorGadget")
CreateStatusBar(0, WindowID(0))
AddStatusBarField(#PB_Ignore)
EditorGadget(0, 10, 10, 160, 60, #PB_Editor_WordWrap)
SetGadgetFont(0, LoadFont(0, "Monaco", 13))
SetGadgetText(0, "The quick brown fox jumps over the lazy dog.")
SetActiveGadget(0)
class_addMethod(DelegateClass, Selector, @SelectionDidChangeCallback(), "v@:@")
CocoaMessage(0, GadgetID(0), "setDelegate:", AppDelegate)
; ----- Set cursor in front of 1st character
CocoaMessage(0, GadgetID(0), "setSelectedRange:@", @Range)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow