Shift-Up/Down selection

This commit is contained in:
Leo Vasanko 2023-11-05 16:07:28 +00:00
parent feaa8e315e
commit 4f370440d9
5 changed files with 22 additions and 6 deletions

1
.gitignore vendored
View File

@ -4,5 +4,4 @@ __pycache__/
*.egg-info/ *.egg-info/
/cista/_version.py /cista/_version.py
/cista/wwwroot/* /cista/wwwroot/*
/cista-front/components.d.ts # Generated
/dist /dist

View File

@ -16,6 +16,7 @@ dist
dist-ssr dist-ssr
coverage coverage
*.local *.local
components.d.ts
/cypress/videos/ /cypress/videos/
/cypress/screenshots/ /cypress/screenshots/

View File

@ -92,10 +92,13 @@ const globalShortcutHandler = (event: KeyboardEvent) => {
} }
if (!timer) { if (!timer) {
// Initial move, then t0 delay until repeats at tr intervals // Initial move, then t0 delay until repeats at tr intervals
documentStore.fileExplorer.cursorMove(vert) const select = event.shiftKey
documentStore.fileExplorer.cursorMove(vert, select)
const t0 = 200, tr = 30 const t0 = 200, tr = 30
timer = setTimeout( timer = setTimeout(
() => timer = setInterval(() => { documentStore.fileExplorer.cursorMove(vert) }, tr), () => timer = setInterval(() => {
documentStore.fileExplorer.cursorMove(vert, select)
}, tr),
t0 - tr t0 - tr
) )
} }

View File

@ -189,7 +189,6 @@ defineExpose({
editing.value = cursor.value editing.value = cursor.value
}, },
cursorSelect() { cursorSelect() {
console.log('select', documentStore.selected)
const doc = cursor.value const doc = cursor.value
if (!doc) return if (!doc) return
if (documentStore.selected.has(doc.key)) { if (documentStore.selected.has(doc.key)) {
@ -199,7 +198,7 @@ defineExpose({
} }
this.cursorMove(1) this.cursorMove(1)
}, },
cursorMove(d: number) { cursorMove(d: number, select = false) {
// Move cursor up or down (keyboard navigation) // Move cursor up or down (keyboard navigation)
const documents = sorted(props.documents as FolderDocument[]) const documents = sorted(props.documents as FolderDocument[])
if (documents.length === 0) { if (documents.length === 0) {
@ -208,10 +207,23 @@ defineExpose({
} }
const mod = (a: number, b: number) => ((a % b) + b) % b const mod = (a: number, b: number) => ((a % b) + b) % b
const index = cursor.value !== null ? documents.indexOf(cursor.value) : -1 const index = cursor.value !== null ? documents.indexOf(cursor.value) : -1
cursor.value = documents[mod(index + d, documents.length + 1)] ?? null const moveto = mod(index + d, documents.length + 1)
cursor.value = documents[moveto] ?? null
const tr = document.getElementById( const tr = document.getElementById(
`file-${cursor.value.key}` `file-${cursor.value.key}`
) as HTMLTableRowElement | null ) as HTMLTableRowElement | null
if (select) {
// Go forwards, possibly wrapping over the end; the last entry is not toggled
let [begin, end] = d > 0 ? [index, moveto] : [moveto, index]
for (let p = begin; p !== end; p = mod(p + 1, documents.length)) {
const doc = documents[p]
if (documentStore.selected.has(doc.key)) {
documentStore.selected.delete(doc.key)
} else {
documentStore.selected.add(doc.key)
}
}
}
// @ts-ignore // @ts-ignore
scrolltr = tr scrolltr = tr
if (!scrolltimer) { if (!scrolltimer) {

View File

@ -3,6 +3,7 @@
ref="input" ref="input"
id="FileRenameInput" id="FileRenameInput"
type="text" type="text"
autocorrect="off"
v-model="name" v-model="name"
@blur="exit" @blur="exit"
@keyup.esc="exit" @keyup.esc="exit"