Page 2 of 4
Re: InFile
Posted: Wednesday 10th February 2021 4:56pm
by cogier
InFile updated
..also after my first try I though some more default options would be good like for example "exclude .gambas files / hidden files / backup files / etc" a little for loop on the resulting string[] after the patern matching was my thought.
I thought long and hard about this but the program works the other way round. Setting the 'Pattern' to '*.class' would not show any .gambas files, hidden files, backup files etc. However, I have added the option to search through multiple 'Patterns'.
New features: -
- You can now search multiple 'Patterns' by separating each 'Pattern' with a comma e.g. *.class,*.form,*.png
- The search time is now displayed
- The context menu now allows you to open a selected folder in your file manager (see Help Requested below)
Help Requested
If 'Desktop.open()' is used to open a folder that's fine, but I have attempted to get your file manager to highlight the actual file. This requires knowing the name of your file manager so that a shell command can be run. (
Shell YourFileManager & " " & "/selected/path/to/file")
This means I need to find out what your file manager's name is. Can you run the program, open the 'Option' and see if the correct file manager has been found? If all is well right-click on a displayed file and select 'Show in your File Manager' and let me know if it highlights that file. Thanks.
Re: InFile
Posted: Wednesday 10th February 2021 7:00pm
by BruceSteers
the file menu on the right is read only (cannot select anything) (needs mode set to single)
(Edit) oh now i see, select and open the dir not the file lol.
My filemanager caja was not detected on mint mate.
maybe because of this? ...
$ xdg-mime query default inode/directory
caja-folder-handler.desktop
Maybe something without xdg , a simple...
For iLoop = 0 To sManagers.Max
sManager = System.Find(sManagers[iLoop])
If sManager Then
bFound = True
Break
Endif
Next
wishing well
Re: InFile
Posted: Wednesday 10th February 2021 8:09pm
by BruceSteers
cogier wrote: ↑Wednesday 10th February 2021 4:56pm
InFile updated
..also after my first try I though some more default options would be good like for example "exclude .gambas files / hidden files / backup files / etc" a little for loop on the resulting string[] after the patern matching was my thought.
I thought long and hard about this but the program works the other way round. Setting the 'Pattern' to '*.class' would not show any .gambas files, hidden files, backup files etc. However, I have added the option to search through multiple 'Patterns'.
I think all my ideas may slow it down too much.
I was thinking along the lines of doing an
xdg-mime query filetype fileName just to be sure the file is a text file not binary.
But i think that might slow it down a lot.
another option would be to quickly run through the resulting file list and remove any file of chosen extensions like *.gambas *~ , etc? I was looking at SearchFile.class Test() function to do it. odd though what i tried seemed to break recursion
Maybe your way is best , to just select the type you want rather than selecting a number of types you would not.
Re: InFile
Posted: Wednesday 10th February 2021 8:45pm
by BruceSteers
Okay Charlie this is what i meant....
I altered the SearchFile.class like this...
The line...
Case "gambas", "zip", "gz", "tar"
any file extension in that list will be skipped when checking.
it's only because the result was returning .gambas files and i thought that was not really useful.
I do not know if the search routine tries to search EVERY file but if yes then omiting a few types might speed things up a bit
Wishing Well
Bruce
Public Sub Main() As String[]
Dim sResult As New String[]
Dim iLoop As Integer
Dim iTemp As Integer
Dim hFile As File
Dim bCheck As Boolean
hFile = Open "/tmp/InFile.txt" For Create
For iLoop = 0 To sDir.Max
Select File.Ext(sDir[iLoop])
Case "gambas", "zip", "gz", "tar"
bCheck = False
Case Else
bCheck = True
End Select
iTemp = Test(sFolder &/ sDir[iLoop])
If iTemp <> 0 And bCheck Then
sResult.Add(sDir[iLoop])
hFile = Open "/tmp/InFile.txt" For Append
Print #hFile, sDir[iLoop]
Close #hFile
End If
Print Str(iLoop + 1) & "," & Str(sResult.Count)
Next
Return sResult
End
I had to let Test() run on every file though , for some reason skipping any Test() calls broke it so not really a speed up :-\
But for sure skipping testing some files will be a speed up
Just a suggestion though m8 , it's your proggy
Bruce
Re: InFile
Posted: Thursday 11th February 2021 10:45am
by cogier
Thanks, Bruce, for the help with the file manager, I have adopted that. I have not added the 'exclusions' as I still feel that you should search in the files you want not exclude the files you don't, the program also has other uses, not just for Gambas, but thanks for the input.
I have published the program on the
Farm
Re: InFile
Posted: Thursday 11th February 2021 12:11pm
by BruceSteers
cogier wrote: ↑Thursday 11th February 2021 10:45am
Thanks, Bruce, for the help with the file manager, I have adopted that. I have not added the 'exclusions' as I still feel that you should search in the files you want not exclude the files you don't, the program also has other uses, not just for Gambas, but thanks for the input.
I have published the program on the
Farm
It's all good m8 , happy to help
One other good thing i managed to accomplish was I noticed when making the exe and with your "Make Desktop Icon" option selected gambas made the icon but did not set it's exe flag so the proper name (without the .desktop ext) and the icon did not show. so i reported that on the bugtracker and it's now been fixed (thank you Benoit)
Great app though, have had many a time when i wanted to find text in a file and had to troll google to find that grep syntax that does it
this app goes in the "ready to be useful" section
Ps. forgot to mention an unimportant typo .....
SetSerachTextBold()
Wishing well
Bruce
Re: InFile
Posted: Thursday 11th February 2021 12:24pm
by BruceSteers
cogier wrote: ↑Thursday 11th February 2021 10:45am
Thanks, Bruce, for the help with the file manager, I have adopted that.
you forgot to remove the now not needed
Shell "xdg-mime query default inode/directory" To sManager
sManager = Split(sManager, ".")[0]
A couple of other suggestions....
(Ps. no need to credit me for any of this lol, I do it just to help
)
The line to open the dir...
Shell Trim(Settings["manager"]) & " " & sFolder &/ GridViewFiles[iLastRow, 0].Text
A shell command might fail if there are spaces in the unquoted path.
would be better as..
Shell Trim(Settings["manager"]) & " " & Quote(sFolder &/ GridViewFiles[iLastRow, 0].Text)
also GridViewFiles_DblClick() copies text and then runs Desktop.Open() , I think that should call MenuFile_Click() or it's not using the filemanager stuff.
(hmm, I may be missreading your code here though and it's actually working as it should, sorry if so.)
All the best m8
Re: InFile
Posted: Thursday 11th February 2021 3:00pm
by BruceSteers
cogier wrote: ↑Wednesday 10th February 2021 4:56pm
InFile updated
Help Requested
If 'Desktop.open()' is used to open a folder that's fine, but I have attempted to get your file manager to highlight the actual file. This requires knowing the name of your file manager so that a shell command can be run. (
Shell YourFileManager & " " & "/selected/path/to/file")
This means I need to find out what your file manager's name is. Can you run the program, open the 'Option' and see if the correct file manager has been found? If all is well right-click on a displayed file and select 'Show in your File Manager' and let me know if it highlights that file. Thanks.
Just a note m8 , this does not work on caja and gives an error..
I do not know how many of the filemanagers do support that action but probably best to only allow it on ones you know that do to save any errors.
snap.png
Re: InFile
Posted: Thursday 11th February 2021 3:10pm
by cogier
Ps. forgot to mention an unimportant typo .....
SetSerachTextBold()
Well spotted!
you forgot to remove the now not needed
Shell "xdg-mime query default inode/directory" To sManager
sManager = Split(sManager, ".")[0]
Opps! However neither of the above should cause a problem.
Shell Trim(Settings["manager"]) & " " & Quote(sFolder &/ GridViewFiles[iLastRow, 0].Text)
I have added this to my copy.
also GridViewFiles_DblClick() copies text and then runs Desktop.Open() , I think that should call MenuFile_Click() or it's not using the filemanager stuff.
(hmm, I may be missreading your code here though and it's actually working as it should, sorry if so.)
You have misread this, the idea is to open the file in whatever is appropriate, not show it in its folder.
Thanks for the input, it's really appreciated.
EDIT
Hi Bruce, I have added some error handling. Can you see if this works on your system? It's a fall back situation not an actual fix so the file in question will not be highlighted, but the program will not fall over. (I hope!)
Public Sub MenuFile_Click()
Dim sResult As String
If Trim(Settings["manager"]) = "" Or Trim(Settings["manager"]) = "NONE" Then
Desktop.Open(sFolder)
Else
Shell Trim(Settings["manager"]) & " " & Quote(sFolder &/ GridViewFiles[iLastRow, 0].Text) & " 2>&1" To sResult
If sResult = "" Then
Shell Trim(Settings["manager"]) & " " & Quote(sFolder &/ GridViewFiles[iLastRow, 0].Text)
Else
Desktop.Open(sFolder)
End If
End If
Catch
Print Error.Text & " at " & Error.Where
End
Re: InFile
Posted: Thursday 11th February 2021 4:10pm
by BruceSteers
cogier wrote: ↑Thursday 11th February 2021 3:10pm
Ps. forgot to mention an unimportant typo .....
SetSerachTextBold()
Well spotted!
you forgot to remove the now not needed
Shell "xdg-mime query default inode/directory" To sManager
sManager = Split(sManager, ".")[0]
Opps! However neither of the above should cause a problem.
Shell Trim(Settings["manager"]) & " " & Quote(sFolder &/ GridViewFiles[iLastRow, 0].Text)
I have added this to my copy.
also GridViewFiles_DblClick() copies text and then runs Desktop.Open() , I think that should call MenuFile_Click() or it's not using the filemanager stuff.
(hmm, I may be missreading your code here though and it's actually working as it should, sorry if so.)
You have misread this, the idea is to open the file in whatever is appropriate, not show it in its folder.
Thanks for the input, it's really appreciated.
Happy to help m8, i know what it's like.
I appreciate the input i get about my programs too, can be a rare thing.
and if a program is worth making better/bug free then it's surely an effort worthwhile
cogier wrote: ↑Thursday 11th February 2021 3:10pm
EDIT
Hi Bruce, I have added some error handling. Can you see if this works on your system? It's a fall back situation not an actual fix so the file in question will not be highlighted, but the program will not fall over. (I hope!)
Public Sub MenuFile_Click()
Dim sResult As String
If Trim(Settings["manager"]) = "" Or Trim(Settings["manager"]) = "NONE" Then
Desktop.Open(sFolder)
Else
Shell Trim(Settings["manager"]) & " " & Quote(sFolder &/ GridViewFiles[iLastRow, 0].Text) & " 2>&1" To sResult
If sResult = "" Then
Shell Trim(Settings["manager"]) & " " & Quote(sFolder &/ GridViewFiles[iLastRow, 0].Text)
Else
Desktop.Open(sFolder)
End If
End If
Catch
Print Error.Text & " at " & Error.Where
End
InFile-1.0.2.tar.gz
Sadly no my friend now it fails and pops up the error twice instead.
It's not a stdout error msg you can read sadly it's a gui message box pops up.
Here's how it works for me..
Sorry I re-wrote a couple of bits like using
If Not sMan instead of If sMan = "" (Benoit always insists on this so i assume it works better/faster)
and changed Shell to Exec as then no need to Quote the string at all
but Note i've only omitted caja from using the "manager" for files , other filemanagers may also fail though if they only accept dir args not files.
Public Sub MenuFile_Click()
Dim sMan As String = Settings["manager"]
If (Not sMan) Or (sMan = "NONE") Or (sMan Ends "caja") Then
Desktop.Open(sFolder)
Else
Exec [sMan, sFolder &/ GridViewFiles[iLastRow, 0].Text]
End If
Catch
Print Error.Text & " at " & Error.Where
End
Wishing well
Bruce