Page 1 of 1

IDE - Recent files menu auto cleanup

Posted: Sun Oct 18, 2015 2:57 pm
by StarBootics
Hello,

Something easy to implement, removing none existing files from "Recent Files" menu.
If the recent files entry don't exist don't add it to the menu.

Edit : When I'm moving or deleting files manually, I'm closing the IDE then I run this program then I restart the IDE.
A built in solution will be much better !
Feel free to adapt to other operating system.

Code: Select all

; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Project name : IDE Recent Files Corrector
; File Name : IDE Recent Files Corrector - Main.pb
; File version: 1.0.0
; Programming : OK
; Programmed by : StarBootics
; Date : 18-10-2015
; Last Update : 18-10-2015
; PureBasic code : V5.40 LTS
; Platform : Linux
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

NewMap RecentFiles.s()

If OpenPreferences(GetHomeDirectory() + ".purebasic/purebasic.prefs")
  
  PreferenceGroup("RecentFiles")
  
  ExaminePreferenceKeys()
  
  While  NextPreferenceKey()
    
    KeyName.s = PreferenceKeyName()
    
    If FindString(KeyName, "RecentFile")
      RecentFiles(KeyName) = PreferenceKeyValue() 
    EndIf
    
  Wend
  
  ForEach RecentFiles()
    
    If FileSize(RecentFiles()) = -1
      RemovePreferenceKey(MapKey(RecentFiles()))
    EndIf
    
  Next
  
  ClosePreferences()
  
EndIf

; <<<<<<<<<<<<<<<<<<<<<<<
; <<<<< END OF FILE <<<<<
; <<<<<<<<<<<<<<<<<<<<<<<
Best regards
StarBootics

Re: IDE - Recent files menu auto cleanup

Posted: Sun Oct 18, 2015 3:01 pm
by ts-soft
+ 1

Re: IDE - Recent files menu auto cleanup

Posted: Sun Oct 18, 2015 4:53 pm
by Tenaja
Or perhaps, instead of removing the file in the list, make it disabled (grayed out) so we can see if a file was accidentally moved/deleted.

Re: IDE - Recent files menu auto cleanup

Posted: Sun Oct 18, 2015 5:32 pm
by StarBootics
Tenaja wrote:Or perhaps, instead of removing the file in the list, make it disabled (grayed out) so we can see if a file was accidentally moved/deleted.
But when they are move/deleted on purpose we will have to deal with zombie entry in the "Recent files" menu.

Re: IDE - Recent files menu auto cleanup

Posted: Sun Oct 18, 2015 5:34 pm
by GPI
StarBootics wrote:
Tenaja wrote:Or perhaps, instead of removing the file in the list, make it disabled (grayed out) so we can see if a file was accidentally moved/deleted.
But when they are move/deleted on purpose we will have to deal with zombie entry in the "Recent files" menu.
Option in the option-menu?

Re: IDE - Recent files menu auto cleanup

Posted: Sun Oct 18, 2015 5:43 pm
by Kiffi
or like in Visual Studio after selecting a non existing item in the recent list:

Image

Greetings ... Peter