473,545 Members | 2,081 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

context-sensitive completion using readline.set_co mpleter


Suppose you have a program containing commands and file name parameters.
A simple class providing completion could first read all the commands
to list, and extend that list later using all file names in given
directory. This way a user could tab-complete (using
readline.parse_ and_bind('tab: complete')) any command and any file. Eg. if
a command 'move' is implemented and there are files 'foo.txt' and
'bar.txt', the user could type

mo<tab> f<tab> b<tab>

expanding to

move foo.txt bar.txt

But the problem is that user is also able to type

"f<tab> m<tab>" getting "foo.txt move", which makes no sense.

The ideal completion would work as follows: when completing the first word
in command line, use set 1 (s1) as possible completion targets. When
completing anything else (second or any other word), use set 2 (s2) as
possible completion targets. Thus, having commands 'move', 'copy' and
'help' with previous two files the session would go as follows:

<tab>
copy move help

c<tab> -> copy

<tab>
foo.txt bar.txt

f<tab> -> copy foo.txt

However I am not able to make it work, because I don't see how I could
store state information to my completer (it has no idea whether I'm
completing the first word or say, 4th word).

--
#!/usr/bin/perl -w
$h={23,69,28,'6 e',2,64,3,76,7, 20,13,61,8,'4d' ,24,73,10,'6a', 12,'6b',21,68,1 4,
72,16,'2c',17,2 0,9,61,11,61,25 ,74,4,61,1,45,2 9,20,5,72,18,61 ,15,69,20,43,26 ,
69,19,20,6,64,2 7,61,22,72};$_= join'',map{chr hex $h->{$_}}sort{$a<= >$b}
keys%$h;m/(\w).*\s(\w+)/x;$_.=uc substr(crypt(jo in('',60,28,14, 49),join'',
map{lc}($1,subs tr $2,4,1)),2,4)." \n"; print;
Jul 18 '05 #1
0 1609

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3023
by: Mohit Gupta | last post by:
Hi all, Lately I have been working on an application in VB .net CF for Pocket PC device. I have a small question about Context Menu. When I try to close the window after context menu is poped up, the window does not closes until I click on the window. Below is the code. Hopefully, you can help me out.
2
1697
by: dave | last post by:
This little problem is driving me nuts!! On my webform page I create 2 variables.. Protected p_dml As String = "I" Public Const mwv_id As Integer = 0 ' originally had mwv_id as Protected
4
1298
by: Hugo Flores | last post by:
Often people post questions about how did they loose their context between pages, and the more common cause is that they don't store the context on the viewstate upon postbacks. Mine is the other way around. Even though I don't fill the context object, I still get it after the Page Load event. May be I'm not understanding the context object...
2
1625
by: Dino M. Buljubasic | last post by:
I have several context menus added to my form. The form is displaying items in listviews connected to the context menus. When I click on an item in a list view, a popup context menu shows allowing me to chese between editing or deleting the item from the list view. That works fine. However, in addition to calling the context menu on Click,...
5
2268
by: lgbjr | last post by:
Hello All, I have several Pictureboxes (linked to an AccessDB) on a VB.NET form. I would like to use a context menu to allow the user to open the picture in their default picture viewer or editor. I'd like to use the same default viewer/editor and open with... choices that are present on the users computer. Does anyone know how I can...
0
896
by: Beat | last post by:
I have a big .NET 2.0 Web Application written in VB. One page passes a reference to context to a class where the processing is done. The class uses context.session, context.request context.application during processing. Everything works fine, as long as not more than 1 user is on the server. Under conditions unknown to me, this class looses...
2
7894
by: Phoe6 | last post by:
Hi all, I have this Code Context feature under Options in the IDLE. How should I use it? Are there folks here who use it regularly and find it useful. Please guide me. Thanks! Senthil
2
1277
by: MooMaster | last post by:
Hey guys, I'm trying to do some black magic voodoo and it's a little late, so forgive me if this question seems obvious or has been asked before. I tried doing a search on context objects and didn't find anything that popped out, and I'm too tired to keep digging. I'm making a little program that is trying to do weird and sexy things by...
4
4678
by: Andrus | last post by:
For winforms application with multiple related forms it is reasonable to create Linq database context object in start of application. Context object is released only when application exits. So connection to database may remain open for all application run time. For such a long time, some routers close connection. This causes Connection is...
4
11936
by: AAaron123 | last post by:
trying to understand the below shown code. After this is run the browser opens a file-save dialog box for saving the file. I wonder how it knows I want the file saved? But more important, the dialog box has as the default file name the name of this ashx file. I'd like to make that name more meaningfull but don't know how it gets set....
0
7401
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7656
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7808
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7423
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5329
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4945
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3450
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1014
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
704
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.