IDE-Tool for activating the ChangeHistory Feature in Scintilla

Working on new editor enhancements?
Axolotl
Addict
Addict
Posts: 837
Joined: Wed Dec 31, 2008 3:36 pm

IDE-Tool for activating the ChangeHistory Feature in Scintilla

Post 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 
 
Just because it worked doesn't mean it works.
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
highend
Enthusiast
Enthusiast
Posts: 169
Joined: Tue Jun 17, 2014 4:49 pm

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

Post by highend »

Very helpful, thanks (again) for sharing!
AZJIO
Addict
Addict
Posts: 2191
Joined: Sun May 14, 2017 1:48 am

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

Post 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)
Post Reply