Jump to content




[CC 1.45+] Shell Tab-Completion v2.2

utility lua

37 replies to this topic

#21 Espen

    Curious Explorer

  • Members
  • 708 posts

Posted 01 December 2012 - 06:07 AM

Ah sorry, didn't read you correctly then. My bad. :)

#22 Ballistic Buddha

  • Members
  • 15 posts

Posted 22 December 2012 - 08:05 AM

Excellent work, this is a godsend! I really can't imagine using the in-game terminal without this now.

However, I do have one suggestion. Is it possible you could add the ability to double-tap tab to display all possibilities for tab-completion, perhaps with a user prompt asking if you want to display all possibilities if there are too many to display on the terminal without scrolling?

If you don't want to add this, that's fine, and I'll probably take a stab at implementing it myself, but I figured I might as well ask.

#23 Espen

    Curious Explorer

  • Members
  • 708 posts

Posted 22 December 2012 - 09:03 AM

@Ballistic Buddha:
Glad to hear it's of use to you. :)

Adding the functionality you suggested is definitely a possibility and shouldn't be too complicated (I guess).
I like the idea, will probably take a look at it in a few days (christmas time = busy time *sigh*), but if you want to give it a shot, be my guest.^^

#24 apottere

  • Members
  • 6 posts

Posted 02 March 2013 - 09:32 PM

Hey, I finally got fed up with the default shell and went looking for something like this. So far it looks pretty sweet, I just had a few questions/comments:

1. How difficult would it be to append a "/" to the end of a directory name that's completed? This would make it more enjoyable, although not necessary.

2. Have you looked into Ballistic Buddha's suggestion yet? Also some more sugar I would appreciate in my shell.

3. With three directories in a folder: foo, foobar, fooness, your autocomplete completes fooness -> foo -> foobar. This is a little wacky (as far as most shell completion goes), would this be a simple fix?

Let me know if/when you'll look into this, I know how pet project timelines go. Thanks!

#25 Espen

    Curious Explorer

  • Members
  • 708 posts

Posted 02 March 2013 - 11:47 PM

@apottere:
1. Adding a slash to the end of a directory name should be possible. That would just need a simple fs.isDir() check in the appropriate place.

2. Not yet, sorry. For reasons see below.

3. It goes through the filelist as fs.list() provides it.
So it would show the directories in the order that e.g. the command "ls" or "dir" should show them.
I could, theoretically, sort the table that fs.list() returns alphabetically.
That would create a little overhead in processing though, the length of which depends on the amount of files and folders in a given directory.
But then again I don't think the average CC user has hundreds or thousands of files/folders in a folder, so that shouldn't be that big of a problem really.

RL-Stuff for the interested:
Spoiler

Thanks for the feedback, much appreciated. ^^

Edited by Espen, 02 March 2013 - 11:48 PM.


#26 apottere

  • Members
  • 6 posts

Posted 03 March 2013 - 08:15 AM

Thanks for the quick response. As for 3, it would make it a lot more intuitive (usually you expect shorter names to be completed first). As for 2, I completely understand, take your time and focus on school. Let me know when you get around to implementing some of this, computercraft desperately needs some better shell completion, and its surprisingly lacking.

#27 Espen

    Curious Explorer

  • Members
  • 708 posts

Posted 03 March 2013 - 09:26 AM

Will do. I never saw this as finished and had a few ideas left the last time I released, so I'll definitely return to it as soon as I can.
And it's university, not school. ^_^
I'm from germany though so I'm not entirely sure if "school" actually means the same in colloquial conversations (in the context of exams).
It's just that in germany "school" only covers everything up to "secondary school" / "highschool", but in english conversations I've seldom heard people speak of "university", even though you'd expect that given the age of the participants involved.

#28 apottere

  • Members
  • 6 posts

Posted 03 March 2013 - 11:31 AM

Yeah, here we mostly just refer to college/university as school, so I was referring to university previously.

#29 elexx

  • Members
  • 9 posts
  • Location/home/elexx

Posted 19 March 2013 - 04:01 AM

Really love this shell extension, great work!

#30 Espen

    Curious Explorer

  • Members
  • 708 posts

Posted 26 March 2013 - 11:02 PM

@apottere:
Unfortunately I'm not going to have much time to improve the program at the moment.
I have 3 group projects this semester and some personal stuff, all of which swallow my time like a vacuum.
That means my plate is full to the brim and I can't work on any hobby-projects. :(

But I invite other people to improve on any of my programs if they want to.
No permission necessary. :)

View Postelexx, on 19 March 2013 - 04:01 AM, said:

Really love this shell extension, great work!
Glad you like it, much appreciated. ^^

#31 electrodude512

  • Members
  • 167 posts
  • LocationEastern USA

Posted 08 May 2013 - 11:22 AM

I made a version that puts a / at the end if it's a directory. It's the injection version. I didn't test it a lot but it seems to work.

http://pastebin.com/d05EZHVz

EDIT: I found a very bad bug, you have to put in the entire path to run a program, don't use this yet...

EDIT2: it's not my bug, the original has this same problem...


EDIT3: no, I just herped up my CC-emu, my version should work for you if the original does.

#32 Espen

    Curious Explorer

  • Members
  • 708 posts

Posted 11 May 2013 - 02:07 PM

Updated to v2.0
The way TAB completions work was completely overhauled.
Before it was really more like in the Windows command prompt, whereas now it's more like Linux TAB completion behaves.

This means if there is more than one match it will fill up as much as it can on first TAB.
If you TAB again, it'll show a list of all possible matches.
I also added the "--More--" functionality if there are more than [screen-height] matches.

Keys for the "More" functionality are:
  • ENTER - Scroll a line
  • SPACE - Scroll a page
  • BACKSPACE - Cancel

Known Limitations:
  • TAB completion doesn't work inbetween arguments, but only on the last.
  • There's only list-view (instead of the separate column-view for small numbers of completions).

Screenshots:
Spoiler

Edited by Espen, 13 May 2013 - 07:07 AM.


#33 electrodude512

  • Members
  • 167 posts
  • LocationEastern USA

Posted 15 May 2013 - 06:37 PM

Yay! Real unix-type tab completions! Can you make it put / at the end if it's a folder? I tried this but it didn't completely work:

http://pastebin.com/d05EZHVz

My changes are on lines 258-260

This is the same thing I did in reply #31. If you type "/ro<tab>" it will print "/rom/" but "/rom<tab>" will leave the prompt at "/rom" and won't put the final "/"

#34 Espen

    Curious Explorer

  • Members
  • 708 posts

Posted 16 May 2013 - 04:29 AM

@electrodude512:
Hehe, I actually had the / code in my working copy for a long time, but didn't release because I already decided to completely overhaul the program for v2.0
And then I simply forgot about putting it in there again, sorry. :\

I'll try to put it in again, but I'll first take a look at how Linux handles it exactly for each case (folder and file matches mixed, only folder matches, only one folder match, etc.).

#35 Espen

    Curious Explorer

  • Members
  • 708 posts

Posted 16 May 2013 - 09:59 AM

Updated to v2.1
Slashes are now appended to directories and I also fixed some bugs I only noticed during development for v2.1

Detailed Changelog for this version:
  • v2.1
    Added: Directory-Matches now have slashes appended to them.
    Changed: COMPLETION_QUERY_ITEMS was hardcoded to 19, is now height of respective terminal.
    Fixed: Pressing SPACE for listing multiple pages of matches "blanked out" the screen.
    Fixed: TAB completion was engaged even if cursor was not at the end of the line.
    Fixed: Path-resolving for directory-detection wasn't quite right.

Enjoy! :)

#36 electrodude512

  • Members
  • 167 posts
  • LocationEastern USA

Posted 16 May 2013 - 12:23 PM

Thanks!

#37 Espen

    Curious Explorer

  • Members
  • 708 posts

Posted 16 May 2013 - 03:47 PM

View Postelectrodude512, on 16 May 2013 - 12:23 PM, said:

Thanks!

You're welcome, glad it's of use for someone. ^_^
I've uploaded a new update since the last time:
  • v2.2
    Fixed: Entering a folder name completely and then pressing TAB didn't append a slash.


#38 Ballistic Buddha

  • Members
  • 15 posts

Posted 04 December 2013 - 07:06 PM

For those of you who still use this. I've made a resource pack that contains only this program as a shell replacement.

It can be downloaded here: https://dl.dropboxus...TabComplete.zip





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users