IDE - Recent files menu auto cleanup

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
StarBootics
Addict
Addict
Posts: 1006
Joined: Sun Jul 07, 2013 11:35 am
Location: Canada

IDE - Recent files menu auto cleanup

Post 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
Last edited by StarBootics on Sun Oct 18, 2015 3:34 pm, edited 1 time in total.
The Stone Age did not end due to a shortage of stones !
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: IDE - Recent files menu auto cleanup

Post by ts-soft »

+ 1
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
Tenaja
Addict
Addict
Posts: 1959
Joined: Tue Nov 09, 2010 10:15 pm

Re: IDE - Recent files menu auto cleanup

Post 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.
User avatar
StarBootics
Addict
Addict
Posts: 1006
Joined: Sun Jul 07, 2013 11:35 am
Location: Canada

Re: IDE - Recent files menu auto cleanup

Post 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.
The Stone Age did not end due to a shortage of stones !
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Re: IDE - Recent files menu auto cleanup

Post 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?
User avatar
Kiffi
Addict
Addict
Posts: 1486
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: IDE - Recent files menu auto cleanup

Post by Kiffi »

or like in Visual Studio after selecting a non existing item in the recent list:

Image

Greetings ... Peter
Hygge
Post Reply