[REVISED] Add Notes Into The IDE
Posted: Wed Aug 20, 2025 2:30 am
I wanted to have a convenient place to add notes in my IDE so I compiled the following and added it under [Tools] > [Configure Tools].
Very convenient now.
You can of course test it without adding it to your tools list. Either way, it Will create a file in your %appdata%\Purebasic\ folder.
I hope someone will find it useful. It saves automatically when you close the window.
Very convenient now.
You can of course test it without adding it to your tools list. Either way, it Will create a file in your %appdata%\Purebasic\ folder.
Code: Select all
Global _mess, fontAri11.i, PBNoteFile$, Kreturn.W, PBNoteFile$
fontAri11.i = LoadFont(#PB_Default,"Arial",11)
;fontAri11B.i = LoadFont(#PB_Default,"Arial",11,#PB_Font_Bold)
Procedure AppActivate(handle,title$)
If title$ <> "" : handle=FindWindow_(0,title$) : EndIf
thread1=GetWindowThreadProcessId_(GetForegroundWindow_(),0)
thread2=GetWindowThreadProcessId_(handle,0)
If thread1thread2 : AttachThreadInput_(thread1,thread2,#True) : EndIf
BringWindowToTop_(handle)
SetForegroundWindow_(handle)
If thread1thread2 : AttachThreadInput_(thread1,thread2,#False) : EndIf
ProcedureReturn IsWindow_(handle)
EndProcedure
If AppActivate(0,"SAFE NOTE w/autosave")
End ;Quit ourt here if already ryunning
EndIf
#QuickNote = 1
Procedure savenote()
If CreateFile(4,PBNoteFile$)
s$ = Trim(GetGadgetText(#QuickNote))
WriteString(4, s$)
CloseFile(4)
Else
MessageRequester("Failed","Cannot open "+PBNoteFile$)
EndIf
EndProcedure
#KB_Return = #PB_Shortcut_Return + 49152
#KB_Escape = #PB_Shortcut_Escape + 49152
#Window_16 = 1
#QuickNote = 1
s$ = GetEnvironmentVariable("APPDATA") +"\PureBasic\"
Debug s$
;s$ = "%AppData%\Purebasic"
If SetCurrentDirectory(s$)
PBNoteFile$ = s$ + "PB_QUICK_NOTE.TXT"
Else
MessageRequester("Bad User Path","Cannot determine path to user directory.",0)
End ; Cannot determine user so bail launch
EndIf
hWnd16 = OpenWindow(1, 100,100,310,510, "SAFE NOTE w/autosave", #PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_TitleBar)
If hWnd16
SetGadgetFont(#PB_Default,FontID(fontAri11.i))
EditorGadget(#QuickNote, 5, 5, 270, 500) ; AddKeyboardShortcut(1,#PB_Shortcut_Return,2)
SendMessage_(GadgetID(#QuickNote), #EM_SETTARGETDEVICE, #Null, 0) ; 0=wrap , 1up=linewidth , $FFFFFF(effectively)=wrapoff
;AddKeyboardShortcut(1, #PB_Shortcut_Escape, #KB_Escape)
If FileSize(PBNoteFile$) > 0
;Debug PBNoteFile$
If ReadFile(4,PBNoteFile$)
;UseFile(4)
Repeat
s$ = ReadString(4,#PB_Ascii)
AddGadgetItem(#QuickNote,-1,s$)
Until Eof(4)
CloseFile(4)
Else
MessageRequester("Failed","Cannot open "+PBNoteFile$)
EndIf
EndIf
If GetFocus_() <> GadgetID(#QuickNote)
SetActiveGadget(#QuickNote)
EndIf
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Quit = 1
Case #WM_CHAR
key = EventwParam()
Select key
Case 13
savenote()
Case 27
Quit = 1
EndSelect
EndSelect
Until Quit = 1
savenote()
EndIf