Tabbing

The plugin enables auto completion of native TinyShell command plugins, files and folders. If more than one value is found, all suggestions are printed.

Command line interface

Syntax

Begin typing a plugin command, filename or folder name, and then press the TAB keyboard key, when no TinyShell application is being executed.

keyboard_tabbing.php

  1. <?
  2. require("../plugin.php");
  3. if (is_ajax()) {
  4. if ($_POST["action"] == 'ls') {
  5. $list = @glob($_POST['start']."*");
  6. if ($list) {
  7. $i = 0;
  8. foreach ($list as $k => $v) {
  9. if ($i++) echo "\n";
  10. echo is_dir($v) ? $v."/" : $v;
  11. }
  12. }
  13. }
  14. exit;
  15. }
  16. ?>
  17. /**
  18. * Auto complete from directory
  19. **/
  20. ts.onkeydown.push(function(e) {
  21. if (!this.proc && e.key == 'tab' && !e.shift) {
  22. e.stop();
  23. if (this.cursor_read_line().test(/\s/)) this.ajax_request(this.cursor_autocomplete, "<?php echo $_AJAX_URL?>", "action=ls&start="+encodeURIComponent(this.cursor_read_word()));
  24. else {
  25. // suggest commands
  26. var plugs = [];
  27. for (plugin in TinyShell.plugins) plugs.push(plugin+" ");
  28. plugs.sort();
  29. this.cursor_autocomplete(plugs.join("\n"));
  30. }
  31. return false;
  32. }
  33. return true;
  34. });

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>