Shift-Up/Down selection
This commit is contained in:
parent
feaa8e315e
commit
4f370440d9
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -4,5 +4,4 @@ __pycache__/
|
|||
*.egg-info/
|
||||
/cista/_version.py
|
||||
/cista/wwwroot/*
|
||||
/cista-front/components.d.ts # Generated
|
||||
/dist
|
||||
|
|
1
cista-front/.gitignore
vendored
1
cista-front/.gitignore
vendored
|
@ -16,6 +16,7 @@ dist
|
|||
dist-ssr
|
||||
coverage
|
||||
*.local
|
||||
components.d.ts
|
||||
|
||||
/cypress/videos/
|
||||
/cypress/screenshots/
|
||||
|
|
|
@ -92,10 +92,13 @@ const globalShortcutHandler = (event: KeyboardEvent) => {
|
|||
}
|
||||
if (!timer) {
|
||||
// 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
|
||||
timer = setTimeout(
|
||||
() => timer = setInterval(() => { documentStore.fileExplorer.cursorMove(vert) }, tr),
|
||||
() => timer = setInterval(() => {
|
||||
documentStore.fileExplorer.cursorMove(vert, select)
|
||||
}, tr),
|
||||
t0 - tr
|
||||
)
|
||||
}
|
||||
|
|
|
@ -189,7 +189,6 @@ defineExpose({
|
|||
editing.value = cursor.value
|
||||
},
|
||||
cursorSelect() {
|
||||
console.log('select', documentStore.selected)
|
||||
const doc = cursor.value
|
||||
if (!doc) return
|
||||
if (documentStore.selected.has(doc.key)) {
|
||||
|
@ -199,7 +198,7 @@ defineExpose({
|
|||
}
|
||||
this.cursorMove(1)
|
||||
},
|
||||
cursorMove(d: number) {
|
||||
cursorMove(d: number, select = false) {
|
||||
// Move cursor up or down (keyboard navigation)
|
||||
const documents = sorted(props.documents as FolderDocument[])
|
||||
if (documents.length === 0) {
|
||||
|
@ -208,10 +207,23 @@ defineExpose({
|
|||
}
|
||||
const mod = (a: number, b: number) => ((a % b) + b) % b
|
||||
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(
|
||||
`file-${cursor.value.key}`
|
||||
) 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
|
||||
scrolltr = tr
|
||||
if (!scrolltimer) {
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
ref="input"
|
||||
id="FileRenameInput"
|
||||
type="text"
|
||||
autocorrect="off"
|
||||
v-model="name"
|
||||
@blur="exit"
|
||||
@keyup.esc="exit"
|
||||
|
|
Loading…
Reference in New Issue
Block a user