forked from goplus/builder
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
742 additions
and
367 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<script setup lang="ts"> | ||
import { computed, useSlots } from 'vue' | ||
import { useI18n } from '@/utils/i18n' | ||
import { type Range, type Position, type TextDocumentIdentifier, textDocumentId2CodeFileName } from './common' | ||
import { useCodeEditorCtx } from './context' | ||
const props = defineProps<{ | ||
file: TextDocumentIdentifier | ||
position?: Position | ||
range?: Range | ||
}>() | ||
const slots = useSlots() | ||
const i18n = useI18n() | ||
const codeEditorCtx = useCodeEditorCtx() | ||
const codeFileName = computed(() => i18n.t(textDocumentId2CodeFileName(props.file))) | ||
const defaultText = computed(() => { | ||
const { position, range } = props | ||
if (position != null) | ||
return i18n.t({ | ||
en: `${codeFileName.value}: Line ${position.line} Col ${position.column}`, | ||
zh: `${codeFileName.value}: 第 ${position.line} 行 第 ${position.column} 列` | ||
}) | ||
if (range != null) { | ||
const { start, end } = range | ||
if (start.line === end.line) { | ||
return i18n.t({ | ||
en: `${codeFileName.value}: Line ${start.line} Col ${start.column}-${end.column}`, | ||
zh: `${codeFileName.value}: 第 ${start.line} 行 第 ${start.column}-${end.column} 列` | ||
}) | ||
} else { | ||
return i18n.t({ | ||
en: `${codeFileName.value}: Line ${start.line}-${end.line}`, | ||
zh: `${codeFileName.value}: 第 ${start.line}-${end.line} 行` | ||
}) | ||
} | ||
} | ||
throw new Error('Either `position` or `range` must be provided') | ||
}) | ||
function handleClick() { | ||
const ui = codeEditorCtx.getAttachedUI() | ||
if (ui == null) return | ||
const { file, position, range } = props | ||
if (position != null) { | ||
ui.open(file, position) | ||
return | ||
} | ||
if (range != null) { | ||
ui.open(file, range) | ||
return | ||
} | ||
throw new Error('Either `position` or `range` must be provided') | ||
} | ||
</script> | ||
|
||
<template> | ||
<a class="code-link" href="javascript:;" @click.prevent="handleClick"> | ||
<template v-if="!!slots.default"> | ||
<slot></slot> | ||
</template> | ||
<template v-else> | ||
{{ defaultText }} | ||
</template> | ||
</a> | ||
</template> | ||
|
||
<style lang="scss" scoped> | ||
@import '@/components/ui/link.scss'; | ||
.code-link { | ||
@include link(boring); | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
spx-gui/src/components/editor/code-editor/ui/ZoomControl.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<script setup lang="ts"> | ||
import iconZoomIn from './icons/zoom-in.svg?raw' | ||
import iconZoomOut from './icons/zoom-out.svg?raw' | ||
import iconZoomReset from './icons/zoom-reset.svg?raw' | ||
const emit = defineEmits<{ | ||
in: [] | ||
out: [] | ||
reset: [] | ||
}>() | ||
</script> | ||
|
||
<template> | ||
<div class="zoomer"> | ||
<!-- eslint-disable vue/no-v-html --> | ||
<button class="zoom-btn" title="Zoom in" @click="emit('in')" v-html="iconZoomIn" /> | ||
<button class="zoom-btn" title="Zoom out" @click="emit('out')" v-html="iconZoomOut" /> | ||
<button class="zoom-btn" title="Reset" @click="emit('reset')" v-html="iconZoomReset" /> | ||
</div> | ||
</template> | ||
|
||
<style lang="scss" scoped> | ||
.zoomer { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
gap: 4px; | ||
} | ||
.zoom-btn { | ||
width: 40px; | ||
height: 40px; | ||
padding: 0; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
border: none; | ||
cursor: pointer; | ||
border-radius: 12px; | ||
color: var(--ui-color-text); | ||
background: none; | ||
transition: background-color 0.2s; | ||
&:hover { | ||
background-color: var(--ui-color-grey-300); | ||
} | ||
&:active { | ||
background-color: var(--ui-color-grey-400); | ||
} | ||
} | ||
</style> |
Oops, something went wrong.