Skip to content

Commit

Permalink
Added Scroll to Top/End actions to the console
Browse files Browse the repository at this point in the history
  • Loading branch information
ethauvin committed Jul 30, 2024
1 parent 075dd87 commit 8a9b5d6
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/main/java/rife/bld/idea/console/BldConsoleActionScrollEnd.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright 2024 Erik C. Thauvin (https://erik.thauvin.net/))
* Licensed under the Apache License, Version 2.0 (the "License")
*/
package rife.bld.idea.console;

import com.intellij.icons.AllIcons;
import com.intellij.idea.ActionsBundle;
import com.intellij.openapi.actionSystem.ActionUpdateThread;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.project.DumbAwareAction;
import org.jetbrains.annotations.NotNull;

class BldConsoleActionScrollEnd extends DumbAwareAction {
public BldConsoleActionScrollEnd() {
super(ActionsBundle.message("action.EditorConsoleScrollToTheEnd.text"), null,
AllIcons.RunConfigurations.Scroll_down);
}

@Override
public @NotNull ActionUpdateThread getActionUpdateThread() {
return ActionUpdateThread.BGT;
}

@Override
public void actionPerformed(AnActionEvent e) {
var project = e.getProject();
if (project != null) {
BldConsoleManager.getConsole(project).requestScrollingToEnd();
}
}
}
32 changes: 32 additions & 0 deletions src/main/java/rife/bld/idea/console/BldConsoleActionScrollTop.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright 2024 Erik C. Thauvin (https://erik.thauvin.net/))
* Licensed under the Apache License, Version 2.0 (the "License")
*/
package rife.bld.idea.console;

import com.intellij.icons.AllIcons;
import com.intellij.idea.ActionsBundle;
import com.intellij.openapi.actionSystem.ActionUpdateThread;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.project.DumbAwareAction;
import org.jetbrains.annotations.NotNull;

class BldConsoleActionScrollTop extends DumbAwareAction {
public BldConsoleActionScrollTop() {
super(ActionsBundle.message("action.EditorScrollTop.text"), null,
AllIcons.RunConfigurations.Scroll_up);
}

@Override
public @NotNull ActionUpdateThread getActionUpdateThread() {
return ActionUpdateThread.BGT;
}

@Override
public void actionPerformed(AnActionEvent e) {
var project = e.getProject();
if (project != null) {
BldConsoleManager.getConsole(project).scrollTo(0);
}
}
}
2 changes: 2 additions & 0 deletions src/main/java/rife/bld/idea/console/BldConsoleViewPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ public void setRowHeight(int i) {
private JPanel createToolbarPanel() {
var group = new DefaultActionGroup();
group.add(new BldConsoleActionStop());
group.add(new BldConsoleActionScrollTop());
group.add(new BldConsoleActionScrollEnd());
group.add(new BldConsoleActionClear());

var toolbar_panel = new JPanel(new BorderLayout());
Expand Down

0 comments on commit 8a9b5d6

Please sign in to comment.