Skip to content

Commit

Permalink
fix(state): Compile error
Browse files Browse the repository at this point in the history
  • Loading branch information
AMythicDev committed Sep 13, 2023
1 parent fb725f3 commit 8d8a78b
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/core/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ use {super::utils::display::write_stdout, crossterm::tty::IsTty};
use parking_lot::Condvar;
use parking_lot::Mutex;

pub static RUNMODE: parking_lot::Mutex<RunMode> = parking_lot::const_mutex(RunMode::Uninitialized);
use super::RUNMODE;

/// The main entry point of minus
///
Expand Down Expand Up @@ -105,7 +105,7 @@ pub fn init_core(mut pager: Pager) -> std::result::Result<(), MinusError> {
// If number of lines of text is less than available wors, write everything and quit
// unless run_no_overflow is set to true
if ps.num_lines() <= ps.rows && !ps.run_no_overflow {
write_stdout(&mut out, &mut ps)?;
write_lines(&mut out, &ps.formatted_lines, Some("\r"))?;
ps.exit();
let mut rm = RUNMODE.lock();
*rm = RunMode::Uninitialized;
Expand Down
2 changes: 2 additions & 0 deletions src/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ pub mod init;
pub mod search;
pub mod utils;

pub static RUNMODE: parking_lot::Mutex<RunMode> = parking_lot::const_mutex(RunMode::Uninitialized);

/// Define the modes in which minus can run
#[derive(Copy, Clone, PartialEq, Eq)]
pub enum RunMode {
Expand Down
2 changes: 1 addition & 1 deletion src/dynamic_pager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::Pager;
/// The function will return with an error if it encounters a error during paging.
#[cfg_attr(docsrs, doc(cfg(feature = "dynamic_output")))]
pub fn dynamic_paging(pager: Pager) -> Result<(), MinusError> {
let mut runmode = init::RUNMODE.lock();
let mut runmode = minus_core::RUNMODE.lock();
assert!(runmode.is_uninitialized(), "Failed to set the RUNMODE. This is caused probably bcause another instance of minus is already running");
*runmode = minus_core::RunMode::Dynamic;
drop(runmode);
Expand Down
10 changes: 5 additions & 5 deletions src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ use crate::{
error::{MinusError, TermError},
input::{self, HashedEventRegister},
minus_core::{
self, init,
utils::text::{self, AppendStyle},
self,
utils::text::{self, AppendStyle, FormatResult},
},
ExitStrategy, LineNumbers,
};
use crossterm::{terminal, tty::IsTty};
#[cfg(feature = "search")]
use parking_lot::{Condvar, Mutex};
use parking_lot::Condvar;
use parking_lot::Mutex;
#[cfg(feature = "search")]
use std::collections::BTreeSet;
use std::{
Expand Down Expand Up @@ -69,7 +70,6 @@ pub struct PagerState {
/// It keeps track of all the numbers that have been entered by the user
/// untill any of `j`, `k`, `G`, `Up` or `Down` is pressed
pub prefix_num: String,

/// Describes whether minus is running and in which mode
pub running: &'static Mutex<crate::RunMode>,

Expand Down Expand Up @@ -149,7 +149,7 @@ impl PagerState {
upper_mark: 0,
unterminated: 0,
prompt,
running: &init::RUNMODE,
running: &minus_core::RUNMODE,
exit_strategy: ExitStrategy::ProcessQuit,
input_classifier: Box::<HashedEventRegister<RandomState>>::default(),
exit_callbacks: Vec::with_capacity(5),
Expand Down
2 changes: 1 addition & 1 deletion src/static_pager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use crate::{error::MinusError, Pager};
/// The function will return with an error if it encounters a error during paging.
#[cfg_attr(docsrs, doc(cfg(feature = "static_output")))]
pub fn page_all(pager: Pager) -> Result<(), MinusError> {
let mut runmode = init::RUNMODE.lock();
let mut runmode = minus_core::RUNMODE.lock();
assert!(runmode.is_uninitialized(), "Failed to set the RUNMODE. This is caused probably bcause another instance of minus is already running");
*runmode = minus_core::RunMode::Static;
drop(runmode);
Expand Down

0 comments on commit 8d8a78b

Please sign in to comment.