Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F173004541
D59606.id186889.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D59606.id186889.diff
View Options
diff --git a/share/man/man4/vt.4 b/share/man/man4/vt.4
--- a/share/man/man4/vt.4
+++ b/share/man/man4/vt.4
@@ -25,7 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd November 21, 2025
+.Dd September 16, 2026
.Dt VT 4
.Os
.Sh NAME
@@ -64,6 +64,8 @@
.Cd kern.vt.kbd_panic= Ns Ar 0
.Cd kern.vt.enable_altgr= Ns Ar 0
.Cd kern.vt.enable_bell= Ns Ar 1
+.Cd kern.vt.mouse_scroll_lines= Ns Ar 3
+.Cd kern.vt.mouse_scroll_reverse= Ns Ar 0
.Sh DESCRIPTION
The
.Nm
@@ -120,6 +122,13 @@
time.
The Home and End keys jump to the beginning or end of the scrollback
buffer.
+By default, the mouse wheel can also be used to scroll up and down while
+scrollback mode is active.
+This behavior is controlled by the
+.Va kern.vt.mouse_scroll_lines
+and
+.Va kern.vt.mouse_scroll_reverse
+sysctl variables.
When finished reviewing, press the Scroll Lock key again to return to
normal use.
Some laptop keyboards lack a Scroll Lock key, and use a special function key
@@ -331,6 +340,16 @@
Disable printing kernel messages to the system console.
.It Va kern.vt.enable_bell
Enable the terminal bell.
+.It Va kern.vt.mouse_scroll_lines
+Set the number of lines to scroll per mouse wheel unit while Scroll Lock
+is enabled.
+Set to 0 to disable mouse wheel scrolling.
+The default is 3.
+.It Va kern.vt.mouse_scroll_reverse
+Set to a non-zero value to reverse the mouse wheel scroll direction while
+Scroll Lock is enabled.
+This behavior is sometimes called natural scrolling.
+The default is 0.
.El
.Sh FILES
.Bl -tag -width "/usr/share/vt/keymaps/*.kbd" -compact
diff --git a/sys/dev/vt/vt_core.c b/sys/dev/vt/vt_core.c
--- a/sys/dev/vt/vt_core.c
+++ b/sys/dev/vt/vt_core.c
@@ -132,6 +132,10 @@
static VT_SYSCTL_INT(debug, 0, "vt(4) debug level");
static VT_SYSCTL_INT(deadtimer, 15, "Time to wait busy process in VT_PROCESS mode");
static VT_SYSCTL_INT(suspendswitch, 1, "Switch to VT0 before suspend");
+static VT_SYSCTL_INT(mouse_scroll_lines, 3,
+ "Lines per mouse wheel unit in scrollback mode (0 disables)");
+static VT_SYSCTL_INT(mouse_scroll_reverse, 0,
+ "Reverse mouse wheel direction in scrollback mode");
/* Slow down and dont rely on timers and interrupts */
static VT_SYSCTL_INT(slow_down, 0, "Non-zero make console slower and synchronous.");
@@ -2388,22 +2392,45 @@
struct vt_window *vw;
struct vt_font *vf;
term_pos_t size;
- int len, mark;
+ int len, mark, scroll_lines;
+ int64_t scroll_limit, scroll_offset;
vd = main_vd;
+ VT_LOCK(vd);
vw = vd->vd_curwindow;
vf = vw->vw_font;
- if (vw->vw_flags & (VWF_MOUSE_HIDE | VWF_GRAPHICS))
+ if (vw->vw_flags & (VWF_MOUSE_HIDE | VWF_GRAPHICS)) {
/*
* Either the mouse is disabled, or the window is in
* "graphics mode". The graphics mode is usually set by
* an X server, using the KDSETMODE ioctl.
*/
+ VT_UNLOCK(vd);
+ return;
+ }
+
+ if (vf == NULL) { /* Text mode. */
+ VT_UNLOCK(vd);
return;
+ }
- if (vf == NULL) /* Text mode. */
+ scroll_lines = vt_mouse_scroll_lines;
+ if ((vw->vw_flags & VWF_SCROLL) != 0 &&
+ (type == MOUSE_ACTION || type == MOUSE_MOTION_EVENT) && z != 0 &&
+ scroll_lines > 0) {
+ scroll_offset = -(int64_t)z * scroll_lines;
+ if (vt_mouse_scroll_reverse != 0)
+ scroll_offset = -scroll_offset;
+ scroll_limit = MIN((uint64_t)vw->vw_buf.vb_history_size,
+ (uint64_t)INT_MAX);
+ scroll_offset = MAX(scroll_offset, -scroll_limit);
+ scroll_offset = MIN(scroll_offset, scroll_limit);
+ vt_scroll(vw, (int)scroll_offset, VHS_CUR);
+ VT_UNLOCK(vd);
return;
+ }
+ VT_UNLOCK(vd);
/*
* TODO: add flag about pointer position changed, to not redraw chars
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Sep 23, 7:34 PM (3 h, 13 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
39114001
Default Alt Text
D59606.id186889.diff (3 KB)
Attached To
Mode
D59606: vt: Allow the mouse wheel to navigate scrollback
Attached
Detach File
Event Timeline
Log In to Comment