Comments (5)
Far's internals shouldn't query the Plugin API at all. FCTL_GETSELECTEDPANELITEM is designed for plugins, allocating and throwing away a PluginPanelItem only to access Description is overkill.
It should already be possible to assess FileList -> FileListItem -> DizText directly, if not - the code can be reorganised to do so. For example, enum_selected() could be moved from Panel to FileList (it belongs there anyway) and yield FileListItem instead of find_data.
from farmanager.
misc/fexcept is definitely not the right place for that.
You need far/fnparce.cpp
May I ask how do you plan to use it?
It should be already possible to get a file description with something like
lua:print(Panel.Item(0, 2, 11))
.
from farmanager.
I would like to use it in a variety of cases, let me list just a few to give you an idea:
- Sometimes I need to unpack a number of archives which are password protected. I would very much like to store the password in the description, and then be able to Ctrl+G and type
7z x -p:!* -o!.0 !.!
to extract all selected archives. (I beg you, please let us not start a deep dive into why or why not or in which cases this might be a good or a bad idea ;-). I have my reasons.) - Sometimes I store a URL associated to some file in a description. Again, I would like to call
wget
on all of these URLs and update the file contents with the response. This would also be a single line from Ctrl+G if a description placeholder existed. - I have a script which generates certain PDF reports from Markdown files, but the script requires an additional parameter (an identifier) which I store in the description. It would be nice if I could create a custom menu item to compile such items, but right now there is no way to access the file description.
Of course, these are all individual cases and all of them can be solved on a case by case basis with Lua macros or by means of other workarounds. Trust me, I have done so.
However, the same type of issue just keeps coming up, having the placeholder for descriptions would be a universal solution to all of them and, I believe, to many others that have not come up yet.
Granted, though, I will absolutely survive without this feature. If you think it's a bad idea, just ignore it.
from farmanager.
I'm not saying it's a bad idea. Perhaps a little controversial - every other special symbol there is for some part of file name, while description is more like 'metadata'. However, it looks useful in your examples.
from farmanager.
The following code would implement this (as long as a reasonable token description = L"!*"sv
is defined):
if (const auto Tail = tokens::skip(CurStr, tokens::description))
{
FarGetPluginPanelItem CurrentItem = { sizeof(FarGetPluginPanelItem) };
const auto Panel = ( SubstData.PassivePanel ? SubstData.Another.Panel : SubstData.This.Panel );
const auto ItemSize = Panel->SetPluginCommand(FCTL_GETSELECTEDPANELITEM, 0, NULL);
CurrentItem.Item = static_cast<struct PluginPanelItem*>(malloc(ItemSize));
if (CurrentItem.Item) {
CurrentItem.Size = ItemSize;
if (Panel->SetPluginCommand(FCTL_GETSELECTEDPANELITEM, 0, static_cast<void*>(&CurrentItem))
&& CurrentItem.Item->Description)
{
Out += CurrentItem.Item->Description;
}
free(CurrentItem.Item);
}
return Tail;
}
This works because Ctrl+G is always operating on the first item which is currently selected, and if no item is selected, FCTL_GETSELECTEDPANELITEM
returns the item under the cursor which also works as intended.
However, the rest of the code is designed to pass all relevant substitution information (file names) to SubstFileName
separately rather than have ProcessMetasymbols
query the API for results, so this seems a little inconsistent, and I am a little worried that the above is not the way it's supposed to be.
Comments, thoughts? Would you accept this PR? I am gladly willing to invest more time into this if you would wish for a different solution.
from farmanager.
Related Issues (20)
- Pressing the folder shortcut key multiple times should toggle selected folder if there are multiple folders bound to the same key. HOT 3
- Find file (ALT-F7). Searching the archives
- Ignore leading spaces in command line HOT 9
- Issue with left mouse click outside of autocomplete history list HOT 1
- Backspace does not open user menu of parent folder HOT 4
- Colors from deleted lines are reused causing spurious colors in the editor HOT 2
- "Can't replace the file" error on first edit of file with elevation HOT 1
- Search results dialog (Alt-F7) does not refresh screen when moving HOT 1
- Autocomplete dropdown disappears on navigation with arrow keys HOT 14
- Crash HOT 2
- Far silently crashes on FTP connection attempt HOT 4
- filenames with Chinese UTF-8 chars spoils alignment in panel view HOT 2
- After exiting the drawio application, the Far panel view is distorted, needs manual reset HOT 1
- Can create CON and NUL files but cannot rename to that names HOT 2
- Viewer: кое что можно что то улучшить? HOT 1
- QuickView enters an unstoppable loop
- при просмотре файла в режиме UTF-8 видны элементы прежних элементов на панели HOT 4
- Crash related to NetBox HOT 6
- Crash in NetBox after some inactivity HOT 10
- Чекбокс для обратного поиска в файле HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from farmanager.