[Konsole-devel] Code'n Greets (File recognition in konsole)

Rodrigo Fernandes rfernandes at gmx.com
Sun May 20 18:57:58 UTC 2012


> 于 2012年05月20日 06:28, Rodrigo Fernandes 写道:
> > Greetings fellow konsole developers.
> >
> > First a small introduction for those that might not know me:
> >
> > My name is Rodrigo Fernandes, I've been a open/source / KDE user since 
early
> > version 2.
> >
> > I have extensive academic and professional background in C/C++, and Qt.
> >
> > While I have multiple ideas I'd like to see take shape in KDE, I decided 
to
> > contribute to konsole first, others will follow suit.
> >
> > I've just dabbled in the first of them; integration of file recognition in
> > konsole. Using a small 1min hack (see attached diff) I am now able to open 
files
> > in the same fashion a email or address is linked.
> > Due to the simplicity of the code (and given that I'm looking for some 
sort of
> > "go-a-head blessing") I thought it'd share it before proceeding. It's 
limited
> > to a simplistic regexp, and the usage of $PWD has serious limitations 
(assumes
> > linux only), but it demonstrates the point.
> >
> > To implement a proper version I would have to make some basic changes to 
the
> > hotspots.
> >
> > As such I would very much appreciate your collective feedback. Is this a
> > feature you would like to have ?
> >
> > Thank you,
> >   Rodrigo (cyber_fusion) Fernandes
> 
> 
> Hi Rodrigo:
> 
> Thanks for choosing konsole as your first shot :)
> 
> Unfortunately, it is currently not a good time for adding new feature. 
> KDE SC 4.9 has just been feature frozen two days ago.

Not a problem as the feature is still quite a bit away from being implemented 
and tested, I'll do finish it and wait on the unfreeze. I've already split 
URL/Email into 2 classes instead of being mashed up in one URLFilter, removing 
the need for the (heavy) CompleteUrlRegExp and quite a bit of code, as the 
Filter chain already does the necessary matching. Should further iterative 
developments be listed to the mailing list or directly to you ?

> 
> The idea of recognizing file path is good and useful. But it is not easy 
> to provide a trouble-free implementation.  Here are some of my thoughts 
> about this feature (actually I have considered this feature in my head 
> for sometime).
> 
> The first problem is: what kind of file path should be recognized ?
> 
>    * A plain filename like 'CMakeLists.txt' should better not be taken 
> into consideration, because that would cause too many recognitions when 
> you move the mouse after a plain 'ls' command, which is just noisy and 
> not that useful.
> 

I'm not so sure it's not that useful, but I agree it has serious performance 
implications if done incorrectly.

>    * A absolute path is the safest candidate, since we can always open 
> it regardless of the current working directory of the session.
> 
>    * A relative path like "./src/CMakeLists.txt" or "../src/main.cpp" is 
> very useful, but opening it is highly influenced by the current working 
> directory of the session.  That context-related nature could be quite 
> problematic, especially when taking the filepath in the scrollback into 
> consideration.
> 

It's near impossible to do correct file detection using just regular 
expressions. I think a another child of Filter which inkoves 'stat' as a test 
to creating the hotspots is the way to go, but I'll have to test it properly. 
The coloring command ccze (pertaining file name coloring) is in the spirit of 
what I think a feature like this should be able to do.

> 
> The second problem is :  when should that recognition be enabled?
> 
>    * If the session is in remote connection, such recognition should 
> better be disabled. Unfortunately, the current code simply does not 
> support that kind of flexibility.
> 

For now only local recognition will be supported. But if the localfile filter is 
aware of the foreground application, support could be added to open remote 
files, eg.: by adding sftp:// to files listed within a ssh session

>    * If we are using vim, such recognition should better be disabled, or 
> only absolute path should be supported.
> 
> 
> So it is definitely not easy to provide a trouble-free implementation.

Not a fan of easy problems myself ;)

> 
> By the way, roxterm provides similar feature, which could be used as a 
> reference .
> 

Tried roxterm, but I couldn't find the specific option to activate file 
recognition


In the meanwhile I think I'll take a look into bug fixing, as it helps me learn 
the ins and outs of the current codebase. Being feature frozen that is the 
main concern right now, correct ?

BTW, browsing though the code, I've already found one fairly trivial crash 
condition in the cursor blinking configuration handling; Would you like me to 
open a bug report, or just post the patch + explanation ?

> _______________________________________________
> konsole-devel mailing list
> konsole-devel at kde.org
> https://mail.kde.org/mailman/listinfo/konsole-devel
> 



More information about the konsole-devel mailing list