-
-
Notifications
You must be signed in to change notification settings - Fork 30
VIM Visual Mode #80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Enoumy
wants to merge
14
commits into
darylhjd:main
Choose a base branch
from
Enoumy:visual-mode
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
VIM Visual Mode #80
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
a3c33c2
Added guestLogin config flag
Enoumy 0208819
Documented guestLogin flag
Enoumy 7d05578
Cleaned up credentials with a guard
Enoumy 6b6aa3a
Update app/service/service.go
Enoumy 4a302be
Update app/core/credentials.go
Enoumy f872ddb
Replying to change requests
Enoumy 4ba67bb
Merge branch 'main' of https://github.com/Enoumy/mangadesk
Enoumy 67511a5
Removed unnecessary diffs
Enoumy a85c845
Implemented visual mode for mangadesk
Enoumy 5d41c26
Implemented visual mode for mangadesk
Enoumy 402394a
Merge branch 'visual-mode' of https://github.com/Enoumy/mangadesk int…
Enoumy f88dbd8
Update app/ui/page_inputs.go
Enoumy fa1f8d6
Documented VIM Visual Mode Keybinding
Enoumy aac73d9
use builtin min and max
darylhjd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
---|---|---|
|
@@ -189,6 +189,12 @@ func (p *MangaPage) setHandlers(cancel context.CancelFunc) { | |
return event | ||
}) | ||
|
||
p.Table.SetSelectionChangedFunc(func(row, _column int) { | ||
if p.sWrap.IsInVisualMode() { | ||
p.selectRange(min(row, p.sWrap.VisualStart), max(row, p.sWrap.VisualStart)) | ||
} | ||
}) | ||
|
||
// Set table selected function. | ||
p.Table.SetSelectedFunc(func(row, _ int) { | ||
log.Println("Creating and showing confirm download modal...") | ||
|
@@ -203,16 +209,26 @@ func (p *MangaPage) setHandlers(cancel context.CancelFunc) { | |
|
||
// Set table input captures. | ||
p.Table.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey { | ||
|
||
switch event.Key() { | ||
case tcell.KeyCtrlE: // User selects this manga row. | ||
p.ctrlEInput() | ||
return event | ||
case tcell.KeyCtrlA: // User wants to toggle select All. | ||
p.ctrlAInput() | ||
return event | ||
case tcell.KeyCtrlR: // User wants to toggle read status for Selection. | ||
p.ctrlRInput() | ||
return event | ||
case tcell.KeyCtrlQ: | ||
p.ctrlQInput() | ||
return event | ||
} | ||
|
||
if event.Rune() == 'v' || event.Rune() == 'V' { | ||
p.shiftVInput() | ||
} | ||
|
||
return event | ||
Enoumy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}) | ||
} | ||
|
@@ -234,6 +250,51 @@ func (p *MangaPage) ctrlAInput() { | |
p.markAll() | ||
} | ||
|
||
func (p *MangaPage) selectRange(from, to int) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. comment for this function and the one below would also be great. |
||
start := min(from, to) | ||
end := max(from, to) | ||
|
||
for row := 1; row < p.Table.GetRowCount(); row++ { | ||
if row < start || row > end { | ||
if p.sWrap.HasSelection(row) { | ||
p.markUnselected(row) | ||
} | ||
} else { | ||
if !p.sWrap.HasSelection(row) { | ||
p.markSelected(row) | ||
} | ||
} | ||
} | ||
} | ||
|
||
func min(a, b int) int { | ||
if a < b { | ||
return a | ||
} | ||
return b | ||
} | ||
|
||
func max(a, b int) int { | ||
if a > b { | ||
return a | ||
} | ||
return b | ||
} | ||
|
||
func (p *MangaPage) shiftVInput() { | ||
if p.sWrap.IsInVisualMode() { | ||
p.sWrap.StopVisualSelection() | ||
for row := 1; row < p.Table.GetRowCount(); row++ { | ||
if p.sWrap.HasSelection(row) { | ||
p.markUnselected(row) | ||
} | ||
} | ||
} else { | ||
row, _ := p.Table.GetSelection() | ||
p.sWrap.StartVisualSelection(row) | ||
} | ||
} | ||
|
||
// ctrlRInput : Allows user to toggle read status for a chapter. | ||
func (p *MangaPage) ctrlRInput() { | ||
modal := confirmModal(utils.ToggleReadChapterModalID, | ||
|
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A comment on what this binding does would be useful. See line 182 of same file for example.