You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
2.3 KiB

  1. # vim:ft=zsh:et:sw=4
  2. (( next_word = 2 | 8192 ))
  3. [[ "$__arg_type" = 3 ]] && return 2
  4. typeset -A subcommands
  5. local __first_call="$1" __wrd="$2" __start_pos="$3" __end_pos="$4" subcommand
  6. subcommands=(
  7. help "_"
  8. general "help status hostname permissions logging _"
  9. networking "help on off connectivity _"
  10. radio "help all wifi wwan _"
  11. connection "help show up down add modify clone edit delete monitor reload load import export _"
  12. device "help status show set connect reapply modify disconnect delete monitor wifi lldp _"
  13. agent "help secret polkit all _"
  14. monitor "help _"
  15. _ "_"
  16. )
  17. if (( __first_call )); then
  18. FAST_HIGHLIGHT[chroma-nmcli-subcommand-a]=""
  19. FAST_HIGHLIGHT[chroma-nmcli-subcommand-b]=""
  20. return 1
  21. elif (( in_redirection > 0 || this_word & 128 )) || [[ $__wrd == "<<<" ]]; then
  22. return 1
  23. elif [[ "$2" = -* ]]; then
  24. return 1
  25. elif [[ -z ${FAST_HIGHLIGHT[chroma-nmcli-subcommand-a]} ]]; then
  26. for subcommand in ${(@k)subcommands}; do
  27. [[ $subcommand = $__wrd* ]] && break || subcommand="_"
  28. done
  29. if [[ $subcommand = _ ]]; then
  30. (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) \
  31. && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]}")
  32. else
  33. (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) \
  34. && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}subcommand]}")
  35. fi
  36. FAST_HIGHLIGHT[chroma-nmcli-subcommand-a]="$subcommand"
  37. elif [[ -z ${FAST_HIGHLIGHT[chroma-nmcli-subcommand-b]} ]]; then
  38. for subcommand in ${(s. .)subcommands[${FAST_HIGHLIGHT[chroma-nmcli-subcommand-a]}]}; do
  39. [[ "$subcommand" = $__wrd* ]] && break || subcommand="_"
  40. done
  41. if [[ $subcommand = _ ]]; then
  42. (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) \
  43. && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}incorrect-subtle]}")
  44. else
  45. (( __start=__start_pos-${#PREBUFFER}, __end=__end_pos-${#PREBUFFER}, __start >= 0 )) \
  46. && reply+=("$__start $__end ${FAST_HIGHLIGHT_STYLES[${FAST_THEME_NAME}subcommand]}")
  47. fi
  48. FAST_HIGHLIGHT[chroma-nmcli-subcommand-b]="$subcommand"
  49. else
  50. return 1
  51. fi
  52. (( this_word = next_word ))
  53. _start_pos=$_end_pos
  54. return 0