File tree 6 files changed +24
-2
lines changed
6 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -116,6 +116,7 @@ varies by platform; on Linux it is typically `~/.config`.
116
116
interface_mode = "delayed"
117
117
scroll_past_eof = true
118
118
read_ahead_lines = 20000
119
+ startup_poll_input = true
119
120
wrapping_mode = "word"
120
121
keymap = "mykeymap"
121
122
```
Original file line number Diff line number Diff line change @@ -164,6 +164,9 @@ pub struct Config {
164
164
/// Specify how many lines to read ahead.
165
165
pub read_ahead_lines : usize ,
166
166
167
+ /// Specify whether to poll input during start-up (delayed or direct mode).
168
+ pub startup_poll_input : bool ,
169
+
167
170
/// Specify default wrapping move.
168
171
pub wrapping_mode : WrappingMode ,
169
172
@@ -177,6 +180,7 @@ impl Default for Config {
177
180
interface_mode : Default :: default ( ) ,
178
181
scroll_past_eof : true ,
179
182
read_ahead_lines : crate :: file:: DEFAULT_NEEDED_LINES ,
183
+ startup_poll_input : true ,
180
184
wrapping_mode : Default :: default ( ) ,
181
185
keymap : Default :: default ( ) ,
182
186
}
Original file line number Diff line number Diff line change @@ -64,6 +64,7 @@ pub(crate) fn direct<T: Terminal>(
64
64
progress : Option < & Progress > ,
65
65
events : & mut EventStream ,
66
66
mode : InterfaceMode ,
67
+ poll_input : bool ,
67
68
) -> Result < Outcome > {
68
69
if mode == InterfaceMode :: FullScreen {
69
70
return Ok ( Outcome :: RenderNothing ) ;
@@ -138,8 +139,18 @@ pub(crate) fn direct<T: Terminal>(
138
139
let mut size = term. get_screen_size ( ) . map_err ( Error :: Termwiz ) ?;
139
140
let mut loaded = BitSet :: with_capacity ( loading. capacity ( ) ) ;
140
141
let mut remaining = output_files. len ( ) + error_files. len ( ) ;
142
+ let interval = Duration :: from_millis ( 10 ) ;
141
143
while remaining > 0 {
142
- match events. get ( term, Some ( Duration :: from_millis ( 10 ) ) ) ? {
144
+ let maybe_event = if poll_input {
145
+ events. get ( term, Some ( interval) ) ?
146
+ } else {
147
+ events. try_recv ( ) ?. or_else ( || {
148
+ // Sleep to avoid busy wait
149
+ std:: thread:: sleep ( interval) ;
150
+ None
151
+ } )
152
+ } ;
153
+ match maybe_event {
143
154
Some ( Event :: Loaded ( i) ) => {
144
155
if loading. contains ( i) && loaded. insert ( i) {
145
156
remaining -= 1 ;
Original file line number Diff line number Diff line change @@ -185,6 +185,7 @@ pub(crate) fn start(
185
185
progress. as_ref ( ) ,
186
186
& mut events,
187
187
config. interface_mode ,
188
+ config. startup_poll_input ,
188
189
) ?
189
190
} ;
190
191
match outcome {
Original file line number Diff line number Diff line change @@ -104,7 +104,7 @@ impl EventStream {
104
104
ActionSender :: new ( self . sender ( ) )
105
105
}
106
106
107
- fn try_recv ( & self ) -> Result < Option < Event > , Error > {
107
+ pub ( crate ) fn try_recv ( & self ) -> Result < Option < Event > , Error > {
108
108
match self . recv . try_recv ( ) {
109
109
Ok ( Envelope :: Normal ( event) ) => Ok ( Some ( event) ) ,
110
110
Ok ( Envelope :: Unique ( event, unique) ) => {
Original file line number Diff line number Diff line change @@ -211,6 +211,11 @@ impl Pager {
211
211
self . config . read_ahead_lines = lines;
212
212
}
213
213
214
+ /// Set whether to poll input during start-up (delayed or direct mode).
215
+ pub fn set_startup_poll_input ( & mut self , poll_input : bool ) {
216
+ self . config . startup_poll_input = poll_input;
217
+ }
218
+
214
219
/// Set default wrapping mode. See [`WrappingMode`] for details.
215
220
pub fn set_wrapping_mode ( & mut self , value : impl Into < WrappingMode > ) {
216
221
self . config . wrapping_mode = value. into ( ) ;
You can’t perform that action at this time.
0 commit comments