quake2ts 0.0.427 → 0.0.429

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1815,6 +1815,9 @@ var Command = class {
1815
1815
  var CommandRegistry = class {
1816
1816
  constructor() {
1817
1817
  this.commands = /* @__PURE__ */ new Map();
1818
+ this.history = [];
1819
+ this.historyLimit = 64;
1820
+ this.autocompleteProviders = [];
1818
1821
  }
1819
1822
  register(name, callback, description) {
1820
1823
  const command = new Command(name, callback, description);
@@ -1824,10 +1827,23 @@ var CommandRegistry = class {
1824
1827
  registerCommand(name, callback) {
1825
1828
  this.register(name, callback);
1826
1829
  }
1830
+ registerAutocompleteProvider(provider) {
1831
+ this.autocompleteProviders.push(provider);
1832
+ }
1827
1833
  get(name) {
1828
1834
  return this.commands.get(name);
1829
1835
  }
1830
1836
  execute(commandString) {
1837
+ const trimmed = commandString.trim();
1838
+ if (trimmed.length === 0) {
1839
+ return false;
1840
+ }
1841
+ if (this.history.length === 0 || this.history[this.history.length - 1] !== trimmed) {
1842
+ this.history.push(trimmed);
1843
+ if (this.history.length > this.historyLimit) {
1844
+ this.history.shift();
1845
+ }
1846
+ }
1831
1847
  const parts = this.tokenize(commandString);
1832
1848
  if (parts.length === 0) {
1833
1849
  return false;
@@ -1845,6 +1861,26 @@ var CommandRegistry = class {
1845
1861
  executeCommand(cmd) {
1846
1862
  this.execute(cmd);
1847
1863
  }
1864
+ getHistory() {
1865
+ return [...this.history];
1866
+ }
1867
+ getSuggestions(prefix) {
1868
+ const suggestions = /* @__PURE__ */ new Set();
1869
+ for (const name of this.commands.keys()) {
1870
+ if (name.startsWith(prefix)) {
1871
+ suggestions.add(name);
1872
+ }
1873
+ }
1874
+ for (const provider of this.autocompleteProviders) {
1875
+ const providerSuggestions = provider();
1876
+ for (const suggestion of providerSuggestions) {
1877
+ if (suggestion.startsWith(prefix)) {
1878
+ suggestions.add(suggestion);
1879
+ }
1880
+ }
1881
+ }
1882
+ return Array.from(suggestions).sort();
1883
+ }
1848
1884
  tokenize(text) {
1849
1885
  const args = [];
1850
1886
  let currentArg = "";
@@ -3030,6 +3066,9 @@ var EngineHost = class {
3030
3066
  },
3031
3067
  { ...options.loop, startTimeMs: this.startTimeMs }
3032
3068
  );
3069
+ this.commands.registerAutocompleteProvider(() => {
3070
+ return this.cvars.list().map((cvar) => cvar.name);
3071
+ });
3033
3072
  }
3034
3073
  start() {
3035
3074
  if (this.started) return;