Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

debug: add command to clear the terminal in the $dbg prompt #20625

Merged
merged 3 commits into from Jan 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions vlib/v/debug/debug.v
Expand Up @@ -7,6 +7,7 @@ import os
import math
import readline
import strings
import term

__global g_debugger = Debugger{}

Expand Down Expand Up @@ -37,6 +38,7 @@ mut:
'scope',
'unwatch',
'watch',
'clear',
]
}
}
Expand Down Expand Up @@ -117,6 +119,7 @@ fn (mut d Debugger) print_help() {
println(' scope\t\t\tshow the vars in the current scope')
println(' u, unwatch <var>\tunwatches a variable')
println(' w, watch <var>\twatches a variable')
println(' clear\tClears the terminal window.')
flush_println('')
}

Expand Down Expand Up @@ -271,6 +274,9 @@ pub fn (mut d Debugger) interact(info DebugContextInfo) ! {
}
}
}
'clear' {
term.erase_clear()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why term.erase_clear(), instead of term.clear() ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

term.clear() will have the same visible effect at the end, but will also allow you to scroll upwards, and see the previous lines.
With term.erase_clear(), all the lines in the current screen are erased, and if you scroll, you will not see them, you will only see the lines that were out of sight.

}
'' {
if is_ctrl {
flush_println('')
Expand Down