Page 1 of 1

IDE-Tool for activating the ChangeHistory Feature in Scintilla

Posted: Sat Jan 13, 2024 5:50 pm
by Axolotl
I created another little program to change the IDE / behavior of the IDE.

IMHO this (and others) would also work well directly in the IDE, but the effort is much greater, as the configuration (enable, color, etc.) would mean a lot of changes. And that's a job for the professionals.
HINT: you can use the standard trigger to test first on single files.

Code: Select all

;/=====================================================================================================================
;|
;| File: IDE_ActivateChangeHistory.pb 
;|
;| Purpose : activate the Scintilla Feature Change History. 
;|
;|           LINK: https://www.scintilla.org/ScintillaDoc.html#ChangeHistory 
;|
;|  Trigger: 
;|  · Sourcecode loaded
;|  · New Sourcecode created 
;|  
;|  Suggested Options: 
;|  · Wait until tool quits 
;|  · Run Hidden 
;|  · Hide Tool from the Main menu 
;| 
;\=====================================================================================================================

Define hScintilla 

; --- look for Scintilla (inside the IDE) ---

hScintilla = Val(GetEnvironmentVariable("PB_TOOL_Scintilla")) 
If Not hScintilla  ; if not running by IDE 
  MessageRequester("Fatal Error", "Failed to retrieve PB_TOOL_Scintilla", #PB_MessageRequester_Error) 
  End ; bye bye 
EndIf 

; --- Helper Macros --- 

Macro SciCall(Message, wParam=0, lParam=0) 
  SendMessage_(hScintilla, Message, wParam, lParam) 
EndMacro 

; --- set marker for change history .... 

; solid (full filled) rectangle (looks best) 

SciCall(#SCI_MARKERDEFINE, #SC_MARKNUM_HISTORY_MODIFIED, #SC_MARK_LEFTRECT) 
SciCall(#SCI_MARKERSETBACK, #SC_MARKNUM_HISTORY_MODIFIED, $008CFF) ; == DarkOrange 

; framed rectangle (looks okay) 

; SciCall(#SCI_MARKERDEFINE, #SC_MARKNUM_HISTORY_MODIFIED, #SC_MARK_BAR) 
; SciCall(#SCI_MARKERSETFORE, #SC_MARKNUM_HISTORY_MODIFIED, $008CFF) ; == DarkOrange 

; SciCall(#SCI_MARKERDEFINE, #SC_MARKNUM_HISTORY_REVERTED_TO_ORIGIN, 0) 
; SciCall(#SCI_MARKERSETBACK, #SC_MARKNUM_HISTORY_REVERTED_TO_ORIGIN, $f0f0f0) ; == DarkOrange 

; don't show the saved marker 
SciCall(#SCI_MARKERDEFINE, #SC_MARKNUM_HISTORY_SAVED, #SC_MARK_EMPTY) 


; --- set all on  
; SciCall(#SCI_SETCHANGEHISTORY, #SC_CHANGE_HISTORY_ENABLED | #SC_CHANGE_HISTORY_MARKERS | #SC_CHANGE_HISTORY_INDICATORS) 

; set marker only 
SciCall(#SCI_SETCHANGEHISTORY, #SC_CHANGE_HISTORY_ENABLED | #SC_CHANGE_HISTORY_MARKERS) 

; ; this commands reset the history (PB-IDE is doing this after saving) 
; 
;   SciCall(#SCI_SETUNDOCOLLECTION, 1)  ; activate undo buffer 
;   SciCall(#SCI_EMPTYUNDOBUFFER)       ; 
;   SciCall(#SCI_SETSAVEPOINT)          ; at this point the doc is unmodified 
 

Re: IDE-Tool for activating the ChangeHistory Feature in Scintilla

Posted: Sun Jan 14, 2024 9:09 pm
by highend
Very helpful, thanks (again) for sharing!

Re: IDE-Tool for activating the ChangeHistory Feature in Scintilla

Posted: Mon Jan 15, 2024 5:05 pm
by AZJIO

Code: Select all

Define hScintilla

hScintilla = Val(GetEnvironmentVariable("PB_TOOL_Scintilla")) 
If Not hScintilla  ; if not running by IDE 
  MessageRequester("Fatal Error", "Failed to retrieve PB_TOOL_Scintilla", #PB_MessageRequester_Error) 
  End ; bye bye 
EndIf 

Macro SciCall(Message, wParam=0, lParam=0)
  SendMessage_(hScintilla, Message, wParam, lParam) 
EndMacro

SciCall(#SCI_MARKERDEFINE, #SC_MARKNUM_HISTORY_MODIFIED, #SC_MARK_LEFTRECT)
SciCall(#SCI_MARKERSETBACK, #SC_MARKNUM_HISTORY_MODIFIED, $00DDFF) ; Изменено (жёлтый)

SciCall(#SCI_MARKERDEFINE, #SC_MARKNUM_HISTORY_SAVED, #SC_MARK_LEFTRECT)
SciCall(#SCI_MARKERSETBACK, #SC_MARKNUM_HISTORY_SAVED, $00CC00)	   ; Сохранено (зелёный)

SciCall(#SCI_MARKERDEFINE, #SC_MARKNUM_HISTORY_REVERTED_TO_ORIGIN, #SC_MARK_LEFTRECT)
SciCall(#SCI_MARKERSETBACK, #SC_MARKNUM_HISTORY_REVERTED_TO_ORIGIN, $FF9900) ; отмена сохранённого (голубой)

SciCall(#SCI_MARKERDEFINE, #SC_MARKNUM_HISTORY_REVERTED_TO_MODIFIED, #SC_MARK_BAR)
SciCall(#SCI_MARKERSETBACK, #SC_MARKNUM_HISTORY_REVERTED_TO_MODIFIED, $00C0A0) ; отмена сохранённого (красный)

SciCall(#SCI_SETCHANGEHISTORY, #SC_CHANGE_HISTORY_ENABLED | #SC_CHANGE_HISTORY_MARKERS)