Start of binary search for ls command
This commit is contained in:
@@ -20,11 +20,21 @@
|
||||
if(!e){
|
||||
throw new Error('cant get width of the teminal element. Its null');
|
||||
}
|
||||
//gets an int from padding property value (which is a string) by cutting last 2 letters "px" and parsing to int
|
||||
const padding: number = parseInt(window.getComputedStyle(e, null).getPropertyValue('padding').slice(0, -2));
|
||||
console.log(padding);
|
||||
return e.clientWidth - (padding * 2);
|
||||
}
|
||||
|
||||
function getFontSize() {
|
||||
const e = document.getElementById('cout');
|
||||
if(!e) {
|
||||
throw new Error('cant get font size of the terminal element. its null');
|
||||
}
|
||||
const size: number = parseInt(window.getComputedStyle(e, null).getPropertyValue('font-size').slice(0, -2));
|
||||
return size;
|
||||
}
|
||||
|
||||
function handleInput(e: KeyboardEvent) {
|
||||
switch (e.key) {
|
||||
case 'Enter': {
|
||||
@@ -54,7 +64,8 @@
|
||||
if (!e) return;
|
||||
printOutput(e, data);
|
||||
},
|
||||
getWidth: getWidth
|
||||
getWidth: getWidth,
|
||||
getFontSize: getFontSize
|
||||
};
|
||||
|
||||
//Test user with basic data so the bash can run
|
||||
|
||||
Reference in New Issue
Block a user