feat: add cursor style option for cli

This commit is contained in:
Lykin 2024-01-23 20:55:38 +08:00
parent d75635bf70
commit edaef2a78c
6 changed files with 54 additions and 5 deletions

View File

@ -30,7 +30,8 @@ func NewPreferences() Preferences {
ShowFolding: true,
},
Cli: PreferencesCli{
FontSize: consts.DEFAULT_FONT_SIZE,
FontSize: consts.DEFAULT_FONT_SIZE,
CursorStyle: "block",
},
}
}
@ -67,6 +68,7 @@ type PreferencesEditor struct {
}
type PreferencesCli struct {
FontFamily []string `json:"fontFamily" yaml:"font_family,omitempty"`
FontSize int `json:"fontSize" yaml:"font_size"`
FontFamily []string `json:"fontFamily" yaml:"font_family,omitempty"`
FontSize int `json:"fontSize" yaml:"font_size"`
CursorStyle string `json:"cursorStyle" yaml:"cursor_style,omitempty"`
}

View File

@ -37,6 +37,7 @@ const newTerm = () => {
allowProposedApi: true,
fontFamily,
fontSize,
cursorStyle: prefStore.cli.cursorStyle || 'block',
cursorBlink: true,
disableStdin: false,
screenReaderMode: true,
@ -102,6 +103,16 @@ watch(
},
)
watch(
() => prefStore.cli.cursorStyle,
(style) => {
if (termInst != null) {
termInst.options.cursorStyle = style || 'block'
}
resizeTerm()
},
)
const prefixContent = computed(() => {
return '\x1b[33m' + promptPrefix.value + '\x1b[0m'
})

View File

@ -214,6 +214,16 @@ const onClose = () => {
<n-form-item-gi :label="$t('preferences.general.font_size')" :span="24">
<n-input-number v-model:value="prefStore.cli.fontSize" :max="65535" :min="1" />
</n-form-item-gi>
<n-form-item-gi :label="$t('preferences.cli.cursor_style')" :span="24">
<n-radio-group v-model:value="prefStore.cli.cursorStyle" name="theme" size="medium">
<n-radio-button
v-for="opt in prefStore.cliCursorStyleOption"
:key="opt.value"
:value="opt.value">
{{ $t(opt.label) }}
</n-radio-button>
</n-radio-group>
</n-form-item-gi>
</n-grid>
</n-form>
</n-tab-pane>

View File

@ -56,7 +56,11 @@
"show_folding": "Enable Code Folding"
},
"cli": {
"name": "Command Line"
"name": "Command Line",
"cursor_style": "Cursor Style",
"cursor_style_block": "Block",
"cursor_style_underline": "Underline",
"cursor_style_bar": "Bar"
}
},
"interface": {

View File

@ -56,7 +56,11 @@
"show_folding": "启用代码折叠"
},
"cli": {
"name": "命令行"
"name": "命令行",
"cursor_style": "光标样式",
"cursor_style_block": "方块",
"cursor_style_underline": "下划线",
"cursor_style_bar": "竖线"
}
},
"interface": {

View File

@ -62,6 +62,7 @@ const usePreferencesStore = defineStore('preferences', {
cli: {
fontFamily: [],
fontSize: 14,
cursorStyle: 'block',
},
lastPref: {},
fontList: [],
@ -191,6 +192,23 @@ const usePreferencesStore = defineStore('preferences', {
return fontStyle
},
cliCursorStyleOption() {
return [
{
value: 'block',
label: 'preferences.cli.cursor_style_block',
},
{
value: 'underline',
label: 'preferences.cli.cursor_style_underline',
},
{
value: 'bar',
label: 'preferences.cli.cursor_style_bar',
},
]
},
/**
* get current language setting
* @return {string}