Skip to content

Commit e8111f3

Browse files
committed
feat: add font api and command
1 parent 33fd1cd commit e8111f3

File tree

3 files changed

+29
-5
lines changed

3 files changed

+29
-5
lines changed

src/components/VueCommand.vue

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
:class="{
55
'vue-command': !invert,
66
'vue-command--invert': invert
7-
}">
7+
}"
8+
:style="font ? { 'font-family': font } : {}">
89
<!-- Bar -->
910
<slot
1011
v-if="!hideBar"
@@ -270,6 +271,12 @@ const props = defineProps({
270271
default: '',
271272
required: false,
272273
type: String
274+
},
275+
276+
font: {
277+
default: undefined,
278+
required: false,
279+
type: String
273280
}
274281
})
275282
@@ -299,7 +306,8 @@ const local = reactive({
299306
historyPosition: props.historyPosition,
300307
isFullscreen: props.isFullscreen,
301308
prompt: props.prompt,
302-
query: props.query
309+
query: props.query,
310+
font: props.font
303311
})
304312
// Signals like SIGINT or SIGKILL
305313
const signals = reactive(newEventBus())
@@ -312,7 +320,8 @@ const terminal = computed(() => ({
312320
invert: props.invert,
313321
isFullscreen: local.isFullscreen,
314322
prompt: local.prompt,
315-
query: local.query
323+
query: local.query,
324+
font: local.font
316325
}))
317326
318327
// Provided commands as programs. It takes the keys of the commands object

src/components/VueCommandQuery.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
autocapitalize="none"
1919
autocorrect="off"
2020
type="text"
21+
:style="terminal.font ? { 'font': `1rem ${terminal.font}`} : {}"
2122
@click="setCursorPosition($refs.queryRef.selectionStart)"
2223
@keydown.tab.exact.prevent="autocompleteQuery"
2324
@keydown.ctrl.r.exact.prevent="showReverseISearch()"
@@ -500,7 +501,6 @@ defineExpose({
500501
.vue-command__multiline-query--invert {
501502
display: flex;
502503
503-
input::placeholder,
504504
input {
505505
font: 1rem Consolas,
506506
Monaco,

src/hosted/App.vue

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
:prompt="prompt"
3030
:options-resolver="optionsResolver"
3131
:show-help="showHelp"
32-
:title="title" />
32+
:title="title"
33+
:font="font" />
3334
</div>
3435

3536
<div class="table-responsive">
@@ -202,6 +203,7 @@ export default {
202203
const query = ref('')
203204
const showHelp = ref(true)
204205
const title = ref('bash - 720x350')
206+
const font = ref('')
205207
206208
const optionsResolver = (program, parsedQuery, setQuery) => {
207209
const lastArgument = parsedQuery[parsedQuery.length - 1]
@@ -260,6 +262,18 @@ export default {
260262
return createStdout('Hello world')
261263
},
262264
265+
changefont: parsedQuery => {
266+
const joinedQuery = parsedQuery.join(' ')
267+
const regex = /(["'])(.*?)\1/
268+
const match = joinedQuery.match(regex)
269+
if (match) {
270+
font.value = match[2]
271+
return createQuery()
272+
}
273+
274+
return createStdout('No quotes found')
275+
},
276+
263277
history: () => {
264278
const history = []
265279
for (const [index, entry] of [...dispatchedQueries.value].entries()) {
@@ -297,6 +311,7 @@ export default {
297311
query,
298312
showHelp,
299313
title,
314+
font,
300315
301316
optionsResolver
302317
}

0 commit comments

Comments
 (0)