Skip to content

Commit

Permalink
Merge pull request #465 from twizzler/feat/font-api
Browse files Browse the repository at this point in the history
feat: add font api and command
  • Loading branch information
ndabAP authored May 30, 2023
2 parents 33fd1cd + e8111f3 commit 02471f9
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
15 changes: 12 additions & 3 deletions src/components/VueCommand.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
:class="{
'vue-command': !invert,
'vue-command--invert': invert
}">
}"
:style="font ? { 'font-family': font } : {}">
<!-- Bar -->
<slot
v-if="!hideBar"
Expand Down Expand Up @@ -270,6 +271,12 @@ const props = defineProps({
default: '',
required: false,
type: String
},
font: {
default: undefined,
required: false,
type: String
}
})
Expand Down Expand Up @@ -299,7 +306,8 @@ const local = reactive({
historyPosition: props.historyPosition,
isFullscreen: props.isFullscreen,
prompt: props.prompt,
query: props.query
query: props.query,
font: props.font
})
// Signals like SIGINT or SIGKILL
const signals = reactive(newEventBus())
Expand All @@ -312,7 +320,8 @@ const terminal = computed(() => ({
invert: props.invert,
isFullscreen: local.isFullscreen,
prompt: local.prompt,
query: local.query
query: local.query,
font: local.font
}))
// Provided commands as programs. It takes the keys of the commands object
Expand Down
2 changes: 1 addition & 1 deletion src/components/VueCommandQuery.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
autocapitalize="none"
autocorrect="off"
type="text"
:style="terminal.font ? { 'font': `1rem ${terminal.font}`} : {}"
@click="setCursorPosition($refs.queryRef.selectionStart)"
@keydown.tab.exact.prevent="autocompleteQuery"
@keydown.ctrl.r.exact.prevent="showReverseISearch()"
Expand Down Expand Up @@ -500,7 +501,6 @@ defineExpose({
.vue-command__multiline-query--invert {
display: flex;
input::placeholder,
input {
font: 1rem Consolas,
Monaco,
Expand Down
17 changes: 16 additions & 1 deletion src/hosted/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
:prompt="prompt"
:options-resolver="optionsResolver"
:show-help="showHelp"
:title="title" />
:title="title"
:font="font" />
</div>

<div class="table-responsive">
Expand Down Expand Up @@ -202,6 +203,7 @@ export default {
const query = ref('')
const showHelp = ref(true)
const title = ref('bash - 720x350')
const font = ref('')
const optionsResolver = (program, parsedQuery, setQuery) => {
const lastArgument = parsedQuery[parsedQuery.length - 1]
Expand Down Expand Up @@ -260,6 +262,18 @@ export default {
return createStdout('Hello world')
},
changefont: parsedQuery => {
const joinedQuery = parsedQuery.join(' ')
const regex = /(["'])(.*?)\1/
const match = joinedQuery.match(regex)
if (match) {
font.value = match[2]
return createQuery()
}
return createStdout('No quotes found')
},
history: () => {
const history = []
for (const [index, entry] of [...dispatchedQueries.value].entries()) {
Expand Down Expand Up @@ -297,6 +311,7 @@ export default {
query,
showHelp,
title,
font,
optionsResolver
}
Expand Down

0 comments on commit 02471f9

Please sign in to comment.