Keyboard shortcuts for Project related actions added. Closes #13

This commit is contained in:
Anis Ahmad
2021-03-09 00:28:07 +06:00
parent ae2dc575b1
commit 0087d6ea1f
3 changed files with 25 additions and 2 deletions

View File

@@ -18,8 +18,8 @@ func NewProjectDetailPane() *ProjectDetailPane {
pane := ProjectDetailPane{
Flex: tview.NewFlex().SetDirection(tview.FlexRow),
}
deleteBtn := makeButton("Delete Project", projectPane.RemoveActivateProject)
clearBtn := makeButton("Clear Completed Tasks", taskPane.ClearCompletedTasks)
deleteBtn := makeButton("[::u]D[::-]elete Project", projectPane.RemoveActivateProject)
clearBtn := makeButton("[::u]C[::-]lear Completed Tasks", taskPane.ClearCompletedTasks)
deleteBtn.SetBackgroundColor(tcell.ColorRed)
pane.
@@ -38,3 +38,20 @@ func (pd *ProjectDetailPane) SetProject(project *model.Project) {
pd.project = project
pd.SetTitle("[::b]" + pd.project.Title)
}
func (pd *ProjectDetailPane) isShowing() bool {
return taskPane.activeTask == nil && projectPane.activeProject != nil
}
func (pd *ProjectDetailPane) handleShortcuts(event *tcell.EventKey) *tcell.EventKey {
switch event.Rune() {
case 'd':
projectPane.RemoveActivateProject()
return nil
case 'c':
taskPane.ClearCompletedTasks()
return nil
}
return event
}