MCPcopy Create free account
hub / github.com/idank/explainshell / adjustcommandfontsize

Function adjustcommandfontsize

explainshell/web/static/js/es.js:963–987  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

961
962// very simple adjustment of the command div font size so it doesn't overflow
963function adjustcommandfontsize() {
964 const commandlength = Array.from(
965 document.querySelectorAll(
966 '#command span[class^=command], #command span[class^=shell]',
967 ),
968 )
969 .reduce((acc, el) => acc + el.textContent, '')
970 .trim().length;
971 let commandfontsize;
972
973 if (commandlength > 105) commandfontsize = '10px';
974 else if (commandlength > 95) commandfontsize = '12px';
975 else if (commandlength > 70) commandfontsize = '14px';
976 else if (commandlength > 60) commandfontsize = '16px';
977
978 if (commandfontsize) {
979 log(
980 'command length',
981 commandlength,
982 ', adjusting font size to',
983 commandfontsize,
984 );
985 document.getElementById('command').style.fontSize = commandfontsize;
986 }
987}
988
989let ignorekeydown = false;
990

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected