Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In Linux, support tab completion of several parameters #256

Closed
yoavnir opened this issue Sep 6, 2024 · 4 comments
Closed

In Linux, support tab completion of several parameters #256

yoavnir opened this issue Sep 6, 2024 · 4 comments
Labels
enhancement New feature or request help wanted Extra attention is needed usability
Milestone

Comments

@yoavnir
Copy link
Owner

yoavnir commented Sep 6, 2024

Specifically:

  • Complete names of stored specifications after -f or --specfile
  • Complete file names for -i or --inFile
  • And --is*
  • And -c or --config
@yoavnir yoavnir added enhancement New feature or request help wanted Extra attention is needed usability labels Sep 6, 2024
@yoavnir
Copy link
Owner Author

yoavnir commented Sep 8, 2024

How it's done:

  • Some session initializer, typically bashrc should call complete -C specs-autocomplete specs
  • Need to put specs-autocomplete in the path.
  • specs-autocomplete` runs in a very specific environment
    • argc is always 4. Exit if not.
    • argv[1] is the command, usually specs
    • argv[2] is what we're completing - can be an empty string after a space, or whatever we have typed since the last space.
    • argv[3] The previous word
    • Env variable COMP_LINE contains all of the stuff on the commad line
    • Env variable COMP_POINT contains the offset (stringified integer) within the line where the cursor is. If it's at the end, then atoi(getenv("COMP_POINT")) == strlen(getenv("COMP_LINE"))
    • Env variable COMP_TYPE has several values:
      • 9 means normal, so if the user typed -f funclnf and the only specfile that starts with funclnf is funclnfreq, the program can output funclnfreq.
      • 63 means tabbing between ambiguous options, so if the user typed -f func and there are both funclnfreq and funcfreq, the program can output funcfreq funclnfreq.
      • 33 when listing alternatives on ambiguous completions
      • 37 for menu completion,
      • 64 to list completions after a partial completion

@yoavnir
Copy link
Owner Author

yoavnir commented Sep 9, 2024

You want to use getFullSpecPath() to get the path, and then search using std::filesystem to get all the some of the files.

As long as we're auto-completing (for -f both from the SPECSPATH and from current directory, for -o ad -i only from current directory). But should also consider what has already been typed...

yoavnir added a commit that referenced this issue Sep 9, 2024
yoavnir added a commit that referenced this issue Sep 9, 2024
@yoavnir
Copy link
Owner Author

yoavnir commented Sep 10, 2024

Maybe use this for multi-compare

std::set<std::string> e{"one", "two", "three", "five", "eight"};

Do it all lower-case and convert the prevToken to lowercase before passing it?

@yoavnir yoavnir added this to the Version 0.9.5 milestone Sep 15, 2024
yoavnir added a commit that referenced this issue Sep 19, 2024
@yoavnir
Copy link
Owner Author

yoavnir commented Sep 19, 2024

I will leave this issue open until I've verified that it works on Ubuntu 24

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed usability
Projects
None yet
Development

No branches or pull requests

1 participant