merge main

This commit is contained in:
Peter Cottle 2022-02-11 10:45:46 -07:00
commit 7d39d63254
8 changed files with 67 additions and 18 deletions

2
.gitignore vendored
View file

@ -47,3 +47,5 @@ VendorLib/Breakpad/src/tools/mac/dump_syms/build
DerivedData
VendorLib/clang/lib/arc
VendorLib/clang/lib/c++
.idea

View file

@ -41,7 +41,7 @@
"flux": "^3.1.3",
"jquery": "^3.4.0",
"jquery-ui": "^1.13.0",
"marked": "^1.0.0",
"marked": "^4.0.10",
"prop-types": "^15.7.2",
"q": "^1.5.1",
"raphael": "^2.1.0",

View file

@ -193,6 +193,7 @@ var getAllCommands = function() {
return allCommands;
};
exports.getAllCommands = getAllCommands;
exports.instantCommands = instantCommands;
exports.parse = util.genParseCommand(regexMap, 'processSandboxCommand');

View file

@ -29,6 +29,7 @@ var toGlobalize = {
TreeCompare: require('../graph/treeCompare'),
Level: require('../level'),
Sandbox: require('../sandbox/'),
SandboxCommands: require('../sandbox/commands'),
GitDemonstrationView: require('../views/gitDemonstrationView'),
Markdown: require('marked'),
LevelDropdownView: require('../views/levelDropdownView'),

View file

@ -1,4 +1,5 @@
var Backbone = require('backbone');
const {getAllCommands} = require('../sandbox/commands');
var Main = require('../app');
var CommandLineStore = require('../stores/CommandLineStore');
@ -7,6 +8,23 @@ var CommandLineActions = require('../actions/CommandLineActions');
var log = require('../log');
var keyboard = require('../util/keyboard');
const allCommands = Object.keys(getAllCommands());
// Lets push a few commands up in the suggestion order,
// which overrides the order from the exportj
const autoCompleteSuggestionOrder = [
'levels', // above "level"
'help', // above help level since you might not be in a level
'show solution', // above show goal since you start with a goal view
'reset', // over reset solved
'import level', // over import tree
];
const allCommandsSorted = autoCompleteSuggestionOrder.concat(
// add the rest that arent in the list above
allCommands.map(command => autoCompleteSuggestionOrder.indexOf(command) > 0 ? null : command)
.filter(command => !!command)
);
var CommandPromptView = Backbone.View.extend({
initialize: function() {
Main.getEvents().on('commandSubmittedPassive', this.addToCommandHistory, this);
@ -49,13 +67,25 @@ var CommandPromptView = Backbone.View.extend({
},
onKeyDown: function(e) {
// If its a tab, prevent losing focus
var el = e.target;
const shadowEl = document.querySelector('#shadow');
const uc = el.value.replace(/ {2,}/g, ' ');
shadowEl.innerHTML = '';
if(uc.length){
for(const c of allCommandsSorted){
if(c.indexOf(uc) === 0){
shadowEl.innerHTML = c;
break;
}
}
}
if (e.keyCode === 9) {
e.preventDefault();
// Maybe one day do tab completion or something? :O
return;
el.value = shadowEl.innerHTML;
}
var el = e.target;
this.updatePrompt(el);
},

View file

@ -1287,3 +1287,12 @@ div.gitDemonstrationView {
border-top-color: #9bcbeb;
background: #9bcbeb;
}
#shadow{
position: absolute;
bottom: 0px;
left: 21px;
opacity: 0.4;
}

View file

@ -407,6 +407,7 @@
<span class="promptSign box">$</span>
<span class="cursor box">&nbsp;</span>
<p class="command"></p>
<div id="shadow"></div>
</div>
<textarea
autocomplete="off"

View file

@ -765,9 +765,9 @@ cacheable-request@^6.0.0:
responselike "^1.0.2"
cached-path-relative@^1.0.0, cached-path-relative@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/cached-path-relative/-/cached-path-relative-1.0.2.tgz#a13df4196d26776220cc3356eb147a52dba2c6db"
integrity sha512-5r2GqsoEb4qMTTN9J+WzXfjov+hjxT+j3u5K+kIVNIwAd99DLCJE9pBIMP1qVeybV6JiijL385Oz0DcYxfbOIg==
version "1.1.0"
resolved "https://registry.yarnpkg.com/cached-path-relative/-/cached-path-relative-1.1.0.tgz#865576dfef39c0d6a7defde794d078f5308e3ef3"
integrity sha512-WF0LihfemtesFcJgO7xfOoOcnWzY/QHR4qeDqV44jPU3HTI54+LnfXK3SA27AVVGCdZFgjjFFaqUA9Jx7dMJZA==
call-bind@^1.0.0:
version "1.0.2"
@ -1051,12 +1051,12 @@ copy-descriptor@^0.1.0:
integrity sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=
copy-props@^2.0.1:
version "2.0.4"
resolved "https://registry.yarnpkg.com/copy-props/-/copy-props-2.0.4.tgz#93bb1cadfafd31da5bb8a9d4b41f471ec3a72dfe"
integrity sha512-7cjuUME+p+S3HZlbllgsn2CDwS+5eCCX16qBgNC4jgSTf49qR1VKy/Zhl400m0IQXl/bPGEVqncgUUMjrr4s8A==
version "2.0.5"
resolved "https://registry.yarnpkg.com/copy-props/-/copy-props-2.0.5.tgz#03cf9ae328d4ebb36f8f1d804448a6af9ee3f2d2"
integrity sha512-XBlx8HSqrT0ObQwmSzM7WE5k8FxTV75h1DX1Z3n6NhQ/UYYAvInWYmG06vFt7hQZArE2fuO62aihiWIVQwh1sw==
dependencies:
each-props "^1.3.0"
is-plain-object "^2.0.1"
each-props "^1.3.2"
is-plain-object "^5.0.0"
core-js@^1.0.0:
version "1.2.7"
@ -1343,7 +1343,7 @@ duplexify@^3.6.0:
readable-stream "^2.0.0"
stream-shift "^1.0.0"
each-props@^1.3.0:
each-props@^1.3.2:
version "1.3.2"
resolved "https://registry.yarnpkg.com/each-props/-/each-props-1.3.2.tgz#ea45a414d16dd5cfa419b1a81720d5ca06892333"
integrity sha512-vV0Hem3zAGkJAyU7JSjixeU66rwdynTAa1vofCrSA5fEln+m67Az9CcnkVD776/fsN/UjIWmBDoNRS6t6G9RfA==
@ -2463,6 +2463,11 @@ is-plain-object@^2.0.1, is-plain-object@^2.0.3, is-plain-object@^2.0.4:
dependencies:
isobject "^3.0.1"
is-plain-object@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-5.0.0.tgz#4427f50ab3429e9025ea7d52e9043a9ef4159344"
integrity sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==
is-posix-bracket@^0.1.0:
version "0.1.1"
resolved "https://registry.yarnpkg.com/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz#3334dc79774368e92f016e6fbc0a88f5cd6e6bc4"
@ -3079,10 +3084,10 @@ map-visit@^1.0.0:
dependencies:
object-visit "^1.0.0"
marked@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/marked/-/marked-1.0.0.tgz#d35784245a04871e5988a491e28867362e941693"
integrity sha512-Wo+L1pWTVibfrSr+TTtMuiMfNzmZWiOPeO7rZsQUY5bgsxpHesBEcIWJloWVTFnrMXnf/TL30eTFSGJddmQAng==
marked@^4.0.10:
version "4.0.10"
resolved "https://registry.yarnpkg.com/marked/-/marked-4.0.10.tgz#423e295385cc0c3a70fa495e0df68b007b879423"
integrity sha512-+QvuFj0nGgO970fySghXGmuw+Fd0gD2x3+MqCWLIPf5oxdv1Ka6b2q+z9RP01P/IaKPMEramy+7cNy/Lw8c3hw==
matchdep@^2.0.0:
version "2.0.0"