mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-29 17:27:22 +02:00
autocomplete implemented
This commit is contained in:
parent
ecb97070eb
commit
863d6cfd5e
5 changed files with 31 additions and 4 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -49,3 +49,5 @@ VendorLib/Breakpad/src/tools/mac/dump_syms/build
|
||||||
DerivedData
|
DerivedData
|
||||||
VendorLib/clang/lib/arc
|
VendorLib/clang/lib/arc
|
||||||
VendorLib/clang/lib/c++
|
VendorLib/clang/lib/c++
|
||||||
|
|
||||||
|
.idea
|
|
@ -193,6 +193,7 @@ var getAllCommands = function() {
|
||||||
return allCommands;
|
return allCommands;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.getAllCommands = getAllCommands;
|
||||||
exports.instantCommands = instantCommands;
|
exports.instantCommands = instantCommands;
|
||||||
exports.parse = util.genParseCommand(regexMap, 'processSandboxCommand');
|
exports.parse = util.genParseCommand(regexMap, 'processSandboxCommand');
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
var Backbone = require('backbone');
|
var Backbone = require('backbone');
|
||||||
|
const {getAllCommands} = require('../sandbox/commands');
|
||||||
|
|
||||||
var Main = require('../app');
|
var Main = require('../app');
|
||||||
var CommandLineStore = require('../stores/CommandLineStore');
|
var CommandLineStore = require('../stores/CommandLineStore');
|
||||||
|
@ -49,13 +50,26 @@ var CommandPromptView = Backbone.View.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
onKeyDown: function(e) {
|
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){
|
||||||
|
const commands = Object.keys(getAllCommands());
|
||||||
|
for(const c of commands){
|
||||||
|
if(c.indexOf(uc) === 0){
|
||||||
|
shadowEl.innerHTML = c;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (e.keyCode === 9) {
|
if (e.keyCode === 9) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
// Maybe one day do tab completion or something? :O
|
el.value = shadowEl.innerHTML;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
var el = e.target;
|
|
||||||
this.updatePrompt(el);
|
this.updatePrompt(el);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -1287,3 +1287,12 @@ div.gitDemonstrationView {
|
||||||
border-top-color: #9bcbeb;
|
border-top-color: #9bcbeb;
|
||||||
background: #9bcbeb;
|
background: #9bcbeb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#shadow{
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0px;
|
||||||
|
left: 21px;
|
||||||
|
opacity: 0.4;
|
||||||
|
}
|
|
@ -407,6 +407,7 @@
|
||||||
<span class="promptSign box">$</span>
|
<span class="promptSign box">$</span>
|
||||||
<span class="cursor box"> </span>
|
<span class="cursor box"> </span>
|
||||||
<p class="command"></p>
|
<p class="command"></p>
|
||||||
|
<div id="shadow"></div>
|
||||||
</div>
|
</div>
|
||||||
<textarea
|
<textarea
|
||||||
autocomplete="off"
|
autocomplete="off"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue