Hi Keith,

I've played with filename completion  for your remarkable
shell. First the good news: it works (for me). The bad news is that
the code is by far not as readable as yours. But I tried my best.

What does it do

Upon startup (and whenver a general update seems appropriate) it
reads the whole directory tree under the current directory and
all directories the environment variable AMFORTH_LIB points to.

While doing so it tries to recognize double occurencies of the
same file (e.g. if ./lib/test.frt and $AMFORTH_LIB/test.frt are
the same file it counts only as one -- difficult to check). For
every file the directories are stored in canonical form in a map
(self._filedirs). Whenever a filename needs to be processed
the program checks if it is unique over all directories (the
map contains 1 entry for that file).

If that check succeeds, the file is processed the usual way.
If not, an error message is printed.

In interactive mode, the #include command works the same.
With filename completion (without telling the number of
directories however).

The drawback of the current code is that you cannot give
directory names any more. Only the filenames itself are
allowed. This is fine for me, but may bother the users.

mt@ayla:~/amforth/trunk/tools$ ./amforth-shell.py -p /dev/ttyUSB0
--no-error-on-output
|I=Entering amforth interactive interpreter
|I=using device.py for atmega328p
(ATmega328P)> #include test<TAB>
test2.frt           tester-amforth.frt  tester.frt
(ATmega328P)> #include test2.frt
|D=#include test2.frt
|I=using test2.frt from /home/mt/amforth/lib
|I=mcudef
|I=using device.py for atmega328p
|F=/home/mt/Projekte/avr/forth/amforth/lib/test2.frt
|C|    1|\ this is a test
|S|    2|100 200 + .
|O|    2|300
|S|    3|1000 ms
(ATmega328P)>

The current code is in the repository (rev 1251)

Matthias

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Amforth-devel mailing list for http://amforth.sf.net/
Amforth-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amforth-devel

Reply via email to