use super::zle_h::{MOD_MULT, MOD_TMULT, MOD_VIBUF, MOD_VIAPP, MOD_NEG, MOD_NULL, MOD_CHAR, MOD_LINE, MOD_PRI, MOD_CLIP, MOD_OSSEL};
#[allow(unused_imports)]
#[allow(unused_imports)]
use crate::ported::zle::zle_main::*;
#[allow(unused_imports)]
use crate::ported::zle::zle_misc::*;
#[allow(unused_imports)]
use crate::ported::zle::zle_hist::*;
#[allow(unused_imports)]
use crate::ported::zle::zle_move::*;
#[allow(unused_imports)]
use crate::ported::zle::zle_params::*;
#[allow(unused_imports)]
use crate::ported::zle::zle_vi::*;
#[allow(unused_imports)]
use crate::ported::zle::zle_utils::*;
#[allow(unused_imports)]
use crate::ported::zle::zle_refresh::*;
#[allow(unused_imports)]
use crate::ported::zle::zle_tricky::*;
#[allow(unused_imports)]
use crate::ported::zle::textobjects::*;
#[allow(unused_imports)]
use crate::ported::zle::deltochar::*;
#[inline] fn zc_iword(c: char) -> bool { c.is_alphanumeric() || c == '_' }
#[inline] fn zc_ialnum(c: char) -> bool { c.is_alphanumeric() }
#[inline] fn zc_ialpha(c: char) -> bool { c.is_alphabetic() }
#[inline] fn zc_iblank(c: char) -> bool { c == ' ' || c == '\t' }
#[inline] fn zc_inblank(c: char) -> bool { c == ' ' || c == '\t' || c == '\n' }
#[inline] fn zc_ipunct(c: char) -> bool { c.is_ascii_punctuation() }
pub fn forwardword(args: &[String]) -> i32 { let n = if crate::ported::zle::zle_main::ZMOD.lock().unwrap().flags & MOD_MULT != 0 { crate::ported::zle::zle_main::ZMOD.lock().unwrap().mult } else { 1 }; if n < 0 { let saved = n;
crate::ported::zle::zle_main::ZMOD.lock().unwrap().mult = -n; crate::ported::zle::zle_main::ZMOD.lock().unwrap().flags |= MOD_MULT; let ret = backwardword(args); crate::ported::zle::zle_main::ZMOD.lock().unwrap().mult = saved; crate::ported::zle::zle_main::ZMOD.lock().unwrap().flags |= MOD_MULT; return ret;
}
let mut n = n;
while n > 0 { n -= 1;
while crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst) != crate::ported::zle::zle_main::ZLELL.load(std::sync::atomic::Ordering::SeqCst) && zc_iword(crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst)]) { crate::ported::zle::zle_main::ZLECS.fetch_add(1, std::sync::atomic::Ordering::SeqCst); }
if false && n == 0 { return 0; }
while crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst) != crate::ported::zle::zle_main::ZLELL.load(std::sync::atomic::Ordering::SeqCst) && !zc_iword(crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst)]) { crate::ported::zle::zle_main::ZLECS.fetch_add(1, std::sync::atomic::Ordering::SeqCst); }
}
0 }
pub fn wordclass(x: char) -> i32 { if zc_iblank(x) { 0 }
else if zc_ialnum(x) || x == '_' { 1 }
else if zc_ipunct(x) { 2 }
else { 3 }
}
pub fn viforwardword(args: &[String]) -> i32 { let mut __g_zmod = crate::ported::zle::zle_main::ZMOD.lock().unwrap();
let n = if __g_zmod.flags & MOD_MULT != 0 { __g_zmod.mult } else { 1 };
if n < 0 { let saved = n;
let mut __g_zmod = crate::ported::zle::zle_main::ZMOD.lock().unwrap();
__g_zmod.mult = -n; __g_zmod.flags |= MOD_MULT;
let ret = vibackwardword(args); let mut __g_zmod = crate::ported::zle::zle_main::ZMOD.lock().unwrap();
__g_zmod.mult = saved; __g_zmod.flags |= MOD_MULT;
return ret;
}
let mut n = n;
while n > 0 { n -= 1;
let cc = wordclass(crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst)]); while crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst) != crate::ported::zle::zle_main::ZLELL.load(std::sync::atomic::Ordering::SeqCst) && wordclass(crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst)]) == cc { crate::ported::zle::zle_main::ZLECS.fetch_add(1, std::sync::atomic::Ordering::SeqCst); }
if false && n == 0 { return 0; } let mut nl = if crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst) < crate::ported::zle::zle_main::ZLELL.load(std::sync::atomic::Ordering::SeqCst) && crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst)] == '\n' { 1 } else { 0 }; while crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst) != crate::ported::zle::zle_main::ZLELL.load(std::sync::atomic::Ordering::SeqCst) && nl < 2
&& zc_inblank(crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst)]) {
crate::ported::zle::zle_main::ZLECS.fetch_add(1, std::sync::atomic::Ordering::SeqCst); if crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst) < crate::ported::zle::zle_main::ZLELL.load(std::sync::atomic::Ordering::SeqCst) && crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst)] == '\n' { nl += 1; } }
}
0 }
pub fn viforwardblankword(args: &[String]) -> i32 { let mut __g_zmod = crate::ported::zle::zle_main::ZMOD.lock().unwrap();
let n = if __g_zmod.flags & MOD_MULT != 0 { __g_zmod.mult } else { 1 };
if n < 0 {
let saved = n;
let mut __g_zmod = crate::ported::zle::zle_main::ZMOD.lock().unwrap();
__g_zmod.mult = -n; __g_zmod.flags |= MOD_MULT;
let ret = vibackwardblankword(args);
let mut __g_zmod = crate::ported::zle::zle_main::ZMOD.lock().unwrap();
__g_zmod.mult = saved; __g_zmod.flags |= MOD_MULT;
return ret;
}
let mut n = n;
while n > 0 {
n -= 1;
while crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst) != crate::ported::zle::zle_main::ZLELL.load(std::sync::atomic::Ordering::SeqCst) && !zc_inblank(crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst)]) { crate::ported::zle::zle_main::ZLECS.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
}
if false && n == 0 { return 0; } let mut nl = if crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst) < crate::ported::zle::zle_main::ZLELL.load(std::sync::atomic::Ordering::SeqCst) && crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst)] == '\n' { 1 } else { 0 };
while crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst) != crate::ported::zle::zle_main::ZLELL.load(std::sync::atomic::Ordering::SeqCst) && nl < 2
&& zc_inblank(crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst)])
{
crate::ported::zle::zle_main::ZLECS.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
if crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst) < crate::ported::zle::zle_main::ZLELL.load(std::sync::atomic::Ordering::SeqCst) && crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst)] == '\n' { nl += 1; }
}
}
0
}
pub fn emacsforwardword(args: &[String]) -> i32 { let mut __g_zmod = crate::ported::zle::zle_main::ZMOD.lock().unwrap();
let n = if __g_zmod.flags & MOD_MULT != 0 { __g_zmod.mult } else { 1 };
if n < 0 { let saved = n;
let mut __g_zmod = crate::ported::zle::zle_main::ZMOD.lock().unwrap();
__g_zmod.mult = -n; __g_zmod.flags |= MOD_MULT;
let ret = emacsbackwardword(args); let mut __g_zmod = crate::ported::zle::zle_main::ZMOD.lock().unwrap();
__g_zmod.mult = saved; __g_zmod.flags |= MOD_MULT;
return ret;
}
let mut n = n;
while n > 0 { n -= 1;
while crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst) != crate::ported::zle::zle_main::ZLELL.load(std::sync::atomic::Ordering::SeqCst) && !zc_iword(crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst)]) { crate::ported::zle::zle_main::ZLECS.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
}
if false && n == 0 { return 0; } while crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst) != crate::ported::zle::zle_main::ZLELL.load(std::sync::atomic::Ordering::SeqCst) && zc_iword(crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst)]) { crate::ported::zle::zle_main::ZLECS.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
}
}
0
}
pub fn viforwardblankwordend(args: &[String]) -> i32 { let mut __g_zmod = crate::ported::zle::zle_main::ZMOD.lock().unwrap();
let n = if __g_zmod.flags & MOD_MULT != 0 { __g_zmod.mult } else { 1 };
if n < 0 {
let saved = n;
let mut __g_zmod = crate::ported::zle::zle_main::ZMOD.lock().unwrap();
__g_zmod.mult = -n; __g_zmod.flags |= MOD_MULT;
let ret = vibackwardblankwordend(args);
let mut __g_zmod = crate::ported::zle::zle_main::ZMOD.lock().unwrap();
__g_zmod.mult = saved; __g_zmod.flags |= MOD_MULT;
return ret;
}
let mut n = n;
while n > 0 {
n -= 1;
while crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst) != crate::ported::zle::zle_main::ZLELL.load(std::sync::atomic::Ordering::SeqCst) { let pos = crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst) + 1; if pos > crate::ported::zle::zle_main::ZLELL.load(std::sync::atomic::Ordering::SeqCst) || !zc_inblank(crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[pos.min(crate::ported::zle::zle_main::ZLELL.load(std::sync::atomic::Ordering::SeqCst).saturating_sub(1))]) {
break;
}
crate::ported::zle::zle_main::ZLECS.store(pos, std::sync::atomic::Ordering::SeqCst); }
while crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst) != crate::ported::zle::zle_main::ZLELL.load(std::sync::atomic::Ordering::SeqCst) { let pos = crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst) + 1; if pos > crate::ported::zle::zle_main::ZLELL.load(std::sync::atomic::Ordering::SeqCst) || zc_inblank(crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[pos.min(crate::ported::zle::zle_main::ZLELL.load(std::sync::atomic::Ordering::SeqCst).saturating_sub(1))]) {
break;
}
crate::ported::zle::zle_main::ZLECS.store(pos, std::sync::atomic::Ordering::SeqCst); }
}
if crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst) != crate::ported::zle::zle_main::ZLELL.load(std::sync::atomic::Ordering::SeqCst) && false { crate::ported::zle::zle_main::ZLECS.fetch_add(1, std::sync::atomic::Ordering::SeqCst); }
0
}
pub fn viforwardwordend(args: &[String]) -> i32 { let mut __g_zmod = crate::ported::zle::zle_main::ZMOD.lock().unwrap();
let n = if __g_zmod.flags & MOD_MULT != 0 { __g_zmod.mult } else { 1 };
if n < 0 {
let saved = n;
let mut __g_zmod = crate::ported::zle::zle_main::ZMOD.lock().unwrap();
__g_zmod.mult = -n; __g_zmod.flags |= MOD_MULT;
let ret = vibackwardwordend(args);
let mut __g_zmod = crate::ported::zle::zle_main::ZMOD.lock().unwrap();
__g_zmod.mult = saved; __g_zmod.flags |= MOD_MULT;
return ret;
}
let mut n = n;
while n > 0 {
n -= 1;
while crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst) != crate::ported::zle::zle_main::ZLELL.load(std::sync::atomic::Ordering::SeqCst) { let pos = crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst) + 1; if pos > crate::ported::zle::zle_main::ZLELL.load(std::sync::atomic::Ordering::SeqCst) || !zc_inblank(crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[pos.min(crate::ported::zle::zle_main::ZLELL.load(std::sync::atomic::Ordering::SeqCst).saturating_sub(1))]) {
break;
}
crate::ported::zle::zle_main::ZLECS.store(pos, std::sync::atomic::Ordering::SeqCst); }
if crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst) != crate::ported::zle::zle_main::ZLELL.load(std::sync::atomic::Ordering::SeqCst) { let mut pos = crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst) + 1; let cc = if pos < crate::ported::zle::zle_main::ZLELL.load(std::sync::atomic::Ordering::SeqCst) { wordclass(crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[pos]) }
else { 0 }; loop { crate::ported::zle::zle_main::ZLECS.store(pos.min(crate::ported::zle::zle_main::ZLELL.load(std::sync::atomic::Ordering::SeqCst)), std::sync::atomic::Ordering::SeqCst); if crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst) == crate::ported::zle::zle_main::ZLELL.load(std::sync::atomic::Ordering::SeqCst) { break; } pos += 1; if pos > crate::ported::zle::zle_main::ZLELL.load(std::sync::atomic::Ordering::SeqCst) || wordclass(crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[pos.min(crate::ported::zle::zle_main::ZLELL.load(std::sync::atomic::Ordering::SeqCst).saturating_sub(1))]) != cc {
break; }
}
}
}
if crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst) != crate::ported::zle::zle_main::ZLELL.load(std::sync::atomic::Ordering::SeqCst) && false { crate::ported::zle::zle_main::ZLECS.fetch_add(1, std::sync::atomic::Ordering::SeqCst); }
0
}
pub fn backwardword(args: &[String]) -> i32 { let mut __g_zmod = crate::ported::zle::zle_main::ZMOD.lock().unwrap();
let n = if __g_zmod.flags & MOD_MULT != 0 { __g_zmod.mult } else { 1 };
if n < 0 { let saved = n;
let mut __g_zmod = crate::ported::zle::zle_main::ZMOD.lock().unwrap();
__g_zmod.mult = -n; __g_zmod.flags |= MOD_MULT;
let ret = forwardword(args); let mut __g_zmod = crate::ported::zle::zle_main::ZMOD.lock().unwrap();
__g_zmod.mult = saved; __g_zmod.flags |= MOD_MULT;
return ret;
}
let mut n = n;
while n > 0 { n -= 1;
while crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst) > 0 { let pos = crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst) - 1; if zc_iword(crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[pos]) { break; } crate::ported::zle::zle_main::ZLECS.store(pos, std::sync::atomic::Ordering::SeqCst); }
while crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst) > 0 { let pos = crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst) - 1; if !zc_iword(crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[pos]) { break; } crate::ported::zle::zle_main::ZLECS.store(pos, std::sync::atomic::Ordering::SeqCst); }
}
0
}
pub fn vibackwardword(args: &[String]) -> i32 { let mut __g_zmod = crate::ported::zle::zle_main::ZMOD.lock().unwrap();
let n = if __g_zmod.flags & MOD_MULT != 0 { __g_zmod.mult } else { 1 };
if n < 0 {
let saved = n;
let mut __g_zmod = crate::ported::zle::zle_main::ZMOD.lock().unwrap();
__g_zmod.mult = -n; __g_zmod.flags |= MOD_MULT;
let ret = viforwardword(args);
let mut __g_zmod = crate::ported::zle::zle_main::ZMOD.lock().unwrap();
__g_zmod.mult = saved; __g_zmod.flags |= MOD_MULT;
return ret;
}
let mut n = n;
while n > 0 {
n -= 1;
let mut nl: i32 = 0; while crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst) > 0 { crate::ported::zle::zle_main::ZLECS.fetch_sub(1, std::sync::atomic::Ordering::SeqCst); if !zc_inblank(crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst)]) { break; } if crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst)] == '\n' { nl += 1; } if nl == 2 { crate::ported::zle::zle_main::ZLECS.fetch_add(1, std::sync::atomic::Ordering::SeqCst); break; }
}
if crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst) > 0 { let mut pos = crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst); let cc = wordclass(crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[pos]); loop { crate::ported::zle::zle_main::ZLECS.store(pos, std::sync::atomic::Ordering::SeqCst); if crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst) == 0 { break; } pos -= 1; if { let __c = crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[pos]; wordclass(__c) != cc || zc_inblank(__c) } {
break; }
}
}
}
0
}
pub fn vibackwardblankword(args: &[String]) -> i32 { let mut __g_zmod = crate::ported::zle::zle_main::ZMOD.lock().unwrap();
let n = if __g_zmod.flags & MOD_MULT != 0 { __g_zmod.mult } else { 1 };
if n < 0 {
let saved = n;
let mut __g_zmod = crate::ported::zle::zle_main::ZMOD.lock().unwrap();
__g_zmod.mult = -n; __g_zmod.flags |= MOD_MULT;
let ret = viforwardblankword(args);
let mut __g_zmod = crate::ported::zle::zle_main::ZMOD.lock().unwrap();
__g_zmod.mult = saved; __g_zmod.flags |= MOD_MULT;
return ret;
}
let mut n = n;
while n > 0 {
n -= 1;
let mut nl: i32 = 0; while crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst) > 0 { let pos = crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst) - 1; if !zc_inblank(crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[pos]) { break; } if crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[pos] == '\n' { nl += 1; } if nl == 2 { break; } crate::ported::zle::zle_main::ZLECS.store(pos, std::sync::atomic::Ordering::SeqCst); }
while crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst) > 0 { let pos = crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst) - 1; if zc_inblank(crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[pos]) { break; } crate::ported::zle::zle_main::ZLECS.store(pos, std::sync::atomic::Ordering::SeqCst); }
}
0
}
pub fn vibackwardwordend(args: &[String]) -> i32 { let mut __g_zmod = crate::ported::zle::zle_main::ZMOD.lock().unwrap();
let n = if __g_zmod.flags & MOD_MULT != 0 { __g_zmod.mult } else { 1 };
if n < 0 {
let saved = n;
let mut __g_zmod = crate::ported::zle::zle_main::ZMOD.lock().unwrap();
__g_zmod.mult = -n; __g_zmod.flags |= MOD_MULT;
let ret = viforwardwordend(args);
let mut __g_zmod = crate::ported::zle::zle_main::ZMOD.lock().unwrap();
__g_zmod.mult = saved; __g_zmod.flags |= MOD_MULT;
return ret;
}
let mut n = n;
while n > 0 && crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst) > 1 { n -= 1;
let cc = wordclass(crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst).min(crate::ported::zle::zle_main::ZLELL.load(std::sync::atomic::Ordering::SeqCst).saturating_sub(1))]); crate::ported::zle::zle_main::ZLECS.fetch_sub(1, std::sync::atomic::Ordering::SeqCst); while crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst) > 0 { if { let __c = crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst)]; wordclass(__c) != cc || zc_iblank(__c) } {
break;
}
crate::ported::zle::zle_main::ZLECS.fetch_sub(1, std::sync::atomic::Ordering::SeqCst); }
while crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst) > 0 && zc_iblank(crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst)]) { crate::ported::zle::zle_main::ZLECS.fetch_sub(1, std::sync::atomic::Ordering::SeqCst); }
}
0
}
pub fn vibackwardblankwordend(args: &[String]) -> i32 { let mut __g_zmod = crate::ported::zle::zle_main::ZMOD.lock().unwrap();
let n = if __g_zmod.flags & MOD_MULT != 0 { __g_zmod.mult } else { 1 };
if n < 0 {
let saved = n;
let mut __g_zmod = crate::ported::zle::zle_main::ZMOD.lock().unwrap();
__g_zmod.mult = -n; __g_zmod.flags |= MOD_MULT;
let ret = viforwardblankwordend(args);
let mut __g_zmod = crate::ported::zle::zle_main::ZMOD.lock().unwrap();
__g_zmod.mult = saved; __g_zmod.flags |= MOD_MULT;
return ret;
}
let mut n = n;
while n > 0 {
n -= 1;
while crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst) > 0 && !zc_inblank(crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst)]) { crate::ported::zle::zle_main::ZLECS.fetch_sub(1, std::sync::atomic::Ordering::SeqCst); }
while crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst) > 0 && zc_inblank(crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst)]) { crate::ported::zle::zle_main::ZLECS.fetch_sub(1, std::sync::atomic::Ordering::SeqCst); }
}
0
}
pub fn emacsbackwardword(args: &[String]) -> i32 { let mut __g_zmod = crate::ported::zle::zle_main::ZMOD.lock().unwrap();
let n = if __g_zmod.flags & MOD_MULT != 0 { __g_zmod.mult } else { 1 };
if n < 0 {
let saved = n;
let mut __g_zmod = crate::ported::zle::zle_main::ZMOD.lock().unwrap();
__g_zmod.mult = -n; __g_zmod.flags |= MOD_MULT;
let ret = emacsforwardword(args); let mut __g_zmod = crate::ported::zle::zle_main::ZMOD.lock().unwrap();
__g_zmod.mult = saved; __g_zmod.flags |= MOD_MULT;
return ret;
}
let mut n = n;
while n > 0 { n -= 1;
while crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst) > 0 { let pos = crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst) - 1; if zc_iword(crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[pos]) { break; } crate::ported::zle::zle_main::ZLECS.store(pos, std::sync::atomic::Ordering::SeqCst); }
while crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst) > 0 { let pos = crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst) - 1; if !zc_iword(crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[pos]) { break; } crate::ported::zle::zle_main::ZLECS.store(pos, std::sync::atomic::Ordering::SeqCst); }
}
0
}
pub fn backwarddeleteword(args: &[String]) -> i32 { let mut x = crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst); let mut __g_zmod = crate::ported::zle::zle_main::ZMOD.lock().unwrap();
let n = if __g_zmod.flags & MOD_MULT != 0 { __g_zmod.mult } else { 1 };
if n < 0 { let saved = n;
let mut __g_zmod = crate::ported::zle::zle_main::ZMOD.lock().unwrap();
__g_zmod.mult = -n; __g_zmod.flags |= MOD_MULT;
let ret = deleteword(args); let mut __g_zmod = crate::ported::zle::zle_main::ZMOD.lock().unwrap();
__g_zmod.mult = saved; __g_zmod.flags |= MOD_MULT;
return ret;
}
let mut n = n;
while n > 0 { n -= 1;
while x > 0 { let pos = x - 1; if zc_iword(crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[pos]) { break; } x = pos;
}
while x > 0 { let pos = x - 1; if !zc_iword(crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[pos]) { break; } x = pos;
}
}
let ct = (crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst) - x) as i32;
crate::ported::zle::zle_utils::backdel(ct, 1); 0
}
pub fn vibackwardkillword(_args: &[String]) -> i32 { let mut x = crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst); let viinsbegin = crate::ported::zle::zle_main::VIINSBEGIN.load(std::sync::atomic::Ordering::SeqCst);
let bol = crate::ported::zle::zle_utils::findbol();
let lim: usize = viinsbegin.max(bol);
let mut __g_zmod = crate::ported::zle::zle_main::ZMOD.lock().unwrap();
let n = if __g_zmod.flags & MOD_MULT != 0 { __g_zmod.mult } else { 1 };
if n < 0 { return 1; } let mut n = n;
while n > 0 { n -= 1;
while x > lim { let pos = x - 1; if !zc_iblank(crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[pos]) { break; } x = pos;
}
if x > lim { let mut pos = x - 1; let cc = wordclass(crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[pos]); loop { x = pos + 1; let xv = pos;
if xv <= lim { x = xv;
break;
}
if pos == 0 { x = 0; break; }
pos -= 1; if wordclass(crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[pos]) != cc { x = pos + 1;
break;
}
x = pos;
}
}
}
let ct = (crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst) - x) as i32;
crate::ported::zle::zle_utils::backkill(ct, 0x02 | 0x04);
0
}
pub fn backwardkillword(args: &[String]) -> i32 { let mut x = crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst); let mut __g_zmod = crate::ported::zle::zle_main::ZMOD.lock().unwrap();
let n = if __g_zmod.flags & MOD_MULT != 0 { __g_zmod.mult } else { 1 };
if n < 0 { let saved = n;
let mut __g_zmod = crate::ported::zle::zle_main::ZMOD.lock().unwrap();
__g_zmod.mult = -n; __g_zmod.flags |= MOD_MULT;
let ret = killword(args); let mut __g_zmod = crate::ported::zle::zle_main::ZMOD.lock().unwrap();
__g_zmod.mult = saved; __g_zmod.flags |= MOD_MULT;
return ret;
}
let mut n = n;
while n > 0 { n -= 1;
while x > 0 { let pos = x - 1; if zc_iword(crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[pos]) { break; } x = pos;
}
while x > 0 { let pos = x - 1; if !zc_iword(crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[pos]) { break; } x = pos;
}
}
let ct = (crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst) - x) as i32;
crate::ported::zle::zle_utils::backkill(ct, 0x02 | 0x04); 0
}
pub fn upcaseword(_args: &[String]) -> i32 { let mut __g_zmod = crate::ported::zle::zle_main::ZMOD.lock().unwrap();
let n = if __g_zmod.flags & MOD_MULT != 0 { __g_zmod.mult } else { 1 };
let neg = n < 0; let ocs = crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst); let mut n = if neg { -n } else { n };
while n > 0 { n -= 1;
while crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst) != crate::ported::zle::zle_main::ZLELL.load(std::sync::atomic::Ordering::SeqCst) && !zc_iword(crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst)]) { crate::ported::zle::zle_main::ZLECS.fetch_add(1, std::sync::atomic::Ordering::SeqCst); }
while crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst) != crate::ported::zle::zle_main::ZLELL.load(std::sync::atomic::Ordering::SeqCst) && zc_iword(crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst)]) { let c = crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst)];
crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst)] = c.to_uppercase().next().unwrap_or(c);
crate::ported::zle::zle_main::ZLECS.fetch_add(1, std::sync::atomic::Ordering::SeqCst); }
}
if neg { crate::ported::zle::zle_main::ZLECS.store(ocs, std::sync::atomic::Ordering::SeqCst); } 0
}
pub fn downcaseword(_args: &[String]) -> i32 { let mut __g_zmod = crate::ported::zle::zle_main::ZMOD.lock().unwrap();
let n = if __g_zmod.flags & MOD_MULT != 0 { __g_zmod.mult } else { 1 };
let neg = n < 0;
let ocs = crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst);
let mut n = if neg { -n } else { n };
while n > 0 {
n -= 1;
while crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst) != crate::ported::zle::zle_main::ZLELL.load(std::sync::atomic::Ordering::SeqCst) && !zc_iword(crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst)]) { crate::ported::zle::zle_main::ZLECS.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
}
while crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst) != crate::ported::zle::zle_main::ZLELL.load(std::sync::atomic::Ordering::SeqCst) && zc_iword(crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst)]) { let c = crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst)];
crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst)] = c.to_lowercase().next().unwrap_or(c); crate::ported::zle::zle_main::ZLECS.fetch_add(1, std::sync::atomic::Ordering::SeqCst); }
}
if neg { crate::ported::zle::zle_main::ZLECS.store(ocs, std::sync::atomic::Ordering::SeqCst); }
0
}
pub fn capitalizeword(_args: &[String]) -> i32 { let mut __g_zmod = crate::ported::zle::zle_main::ZMOD.lock().unwrap();
let n = if __g_zmod.flags & MOD_MULT != 0 { __g_zmod.mult } else { 1 };
let neg = n < 0;
let ocs = crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst);
let mut n = if neg { -n } else { n };
while n > 0 {
n -= 1;
let mut first = true; while crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst) != crate::ported::zle::zle_main::ZLELL.load(std::sync::atomic::Ordering::SeqCst) && !zc_iword(crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst)]) { crate::ported::zle::zle_main::ZLECS.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
}
while crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst) != crate::ported::zle::zle_main::ZLELL.load(std::sync::atomic::Ordering::SeqCst) && { let __c = crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst)]; zc_iword(__c) && !zc_ialpha(__c) } {
crate::ported::zle::zle_main::ZLECS.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
}
while crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst) != crate::ported::zle::zle_main::ZLELL.load(std::sync::atomic::Ordering::SeqCst) && zc_iword(crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst)]) { let c = crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst)];
crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst)] = if first {
c.to_uppercase().next().unwrap_or(c) } else {
c.to_lowercase().next().unwrap_or(c) };
first = false; crate::ported::zle::zle_main::ZLECS.fetch_add(1, std::sync::atomic::Ordering::SeqCst); }
}
if neg { crate::ported::zle::zle_main::ZLECS.store(ocs, std::sync::atomic::Ordering::SeqCst); }
0
}
pub fn deleteword(args: &[String]) -> i32 { let mut x = crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst);
let mut __g_zmod = crate::ported::zle::zle_main::ZMOD.lock().unwrap();
let n = if __g_zmod.flags & MOD_MULT != 0 { __g_zmod.mult } else { 1 };
if n < 0 { let saved = n;
let mut __g_zmod = crate::ported::zle::zle_main::ZMOD.lock().unwrap();
__g_zmod.mult = -n; __g_zmod.flags |= MOD_MULT;
let ret = backwarddeleteword(args); let mut __g_zmod = crate::ported::zle::zle_main::ZMOD.lock().unwrap();
__g_zmod.mult = saved; __g_zmod.flags |= MOD_MULT;
return ret;
}
let mut n = n;
while n > 0 { n -= 1;
while x != crate::ported::zle::zle_main::ZLELL.load(std::sync::atomic::Ordering::SeqCst) && !zc_iword(crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[x]) { x += 1; }
while x != crate::ported::zle::zle_main::ZLELL.load(std::sync::atomic::Ordering::SeqCst) && zc_iword(crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[x]) { x += 1; }
}
let ct = (x - crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst)) as i32;
crate::ported::zle::zle_utils::foredel(ct, 1); 0
}
pub fn killword(args: &[String]) -> i32 { let mut x = crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst);
let mut __g_zmod = crate::ported::zle::zle_main::ZMOD.lock().unwrap();
let n = if __g_zmod.flags & MOD_MULT != 0 { __g_zmod.mult } else { 1 };
if n < 0 { let saved = n;
let mut __g_zmod = crate::ported::zle::zle_main::ZMOD.lock().unwrap();
__g_zmod.mult = -n; __g_zmod.flags |= MOD_MULT;
let ret = backwardkillword(args); let mut __g_zmod = crate::ported::zle::zle_main::ZMOD.lock().unwrap();
__g_zmod.mult = saved; __g_zmod.flags |= MOD_MULT;
return ret;
}
let mut n = n;
while n > 0 { n -= 1;
while x != crate::ported::zle::zle_main::ZLELL.load(std::sync::atomic::Ordering::SeqCst) && !zc_iword(crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[x]) { x += 1; }
while x != crate::ported::zle::zle_main::ZLELL.load(std::sync::atomic::Ordering::SeqCst) && zc_iword(crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[x]) { x += 1; }
}
let ct = (x - crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst)) as i32;
crate::ported::zle::zle_utils::forekill(ct, 1); 0
}
pub fn transposewords(_args: &[String]) -> i32 { let mut __g_zmod = crate::ported::zle::zle_main::ZMOD.lock().unwrap();
let n = if __g_zmod.flags & MOD_MULT != 0 { __g_zmod.mult } else { 1 };
let neg = n < 0;
let ocs = crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst);
let mut n = if neg { -n } else { n };
let mut x = crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst);
while x != crate::ported::zle::zle_main::ZLELL.load(std::sync::atomic::Ordering::SeqCst) && { let __c = crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[x]; __c != '\n' && !zc_iword(__c) } {
x += 1; }
if x == crate::ported::zle::zle_main::ZLELL.load(std::sync::atomic::Ordering::SeqCst) || crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[x] == '\n' { x = crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst); while x > 0 { if zc_iword(crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[x]) { break; } let pos = x - 1;
if crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[pos] == '\n' { break; } x = pos;
}
if x == 0 { return 1; } let pos = x - 1;
if crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[pos] == '\n' { return 1; } }
let mut p4 = x;
while p4 != crate::ported::zle::zle_main::ZLELL.load(std::sync::atomic::Ordering::SeqCst) && zc_iword(crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[p4]) { p4 += 1; }
let mut p3 = p4;
while p3 > 0 { let pos = p3 - 1;
if !zc_iword(crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[pos]) { break; } p3 = pos;
}
if p3 == 0 { return 1; }
let mut p2 = p3;
let mut p1 = p3;
let mut pt = p3;
while n > 0 {
n -= 1;
p2 = pt;
while p2 > 0 { let pos = p2 - 1;
if zc_iword(crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[pos]) { break; } p2 = pos;
}
if p2 == 0 { return 1; } p1 = p2;
while p1 > 0 { let pos = p1 - 1;
if !zc_iword(crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[pos]) { break; } p1 = pos;
}
pt = p1; }
let mut temp: Vec<char> = Vec::with_capacity(p4 - p1);
temp.extend_from_slice(&crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[p3..p4]); temp.extend_from_slice(&crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[p2..p3]); temp.extend_from_slice(&crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[p1..p2]); for (i, c) in temp.iter().enumerate() { crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[p1 + i] = *c;
}
if neg { crate::ported::zle::zle_main::ZLECS.store(ocs, std::sync::atomic::Ordering::SeqCst); } else { crate::ported::zle::zle_main::ZLECS.store(p4, std::sync::atomic::Ordering::SeqCst); } 0
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum WordStyle {
Emacs,
Vi,
Shell,
BlankDelimited,
}
pub fn find_word_start(style: WordStyle) -> usize {
let mut pos = crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst);
match style {
WordStyle::Emacs => {
while pos > 0 && { let __c = crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[pos - 1]; !(__c.is_alphanumeric()
|| __c == '_') } {
pos -= 1;
}
while pos > 0 && { let __c = crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[pos - 1]; (__c.is_alphanumeric()
|| __c == '_') } {
pos -= 1;
}
}
WordStyle::Vi => {
while pos > 0 && crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[pos - 1].is_whitespace() {
pos -= 1;
}
if pos > 0 {
let is_word = crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[pos - 1].is_alphanumeric()
|| crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[pos - 1] == '_';
while pos > 0 {
let c = crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[pos - 1];
if c.is_whitespace()
|| ((c.is_alphanumeric() || c == '_') != is_word) {
break;
}
pos -= 1;
}
}
}
WordStyle::Shell => {
}
WordStyle::BlankDelimited => {
while pos > 0 && crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[pos - 1].is_whitespace() {
pos -= 1;
}
while pos > 0 && !crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[pos - 1].is_whitespace() {
pos -= 1;
}
}
}
pos
}
pub fn find_word_end(style: WordStyle) -> usize {
let mut pos = crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst);
match style {
WordStyle::Emacs => {
while pos < crate::ported::zle::zle_main::ZLELL.load(std::sync::atomic::Ordering::SeqCst) && { let __c = crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[pos]; !(__c.is_alphanumeric()
|| __c == '_') } {
pos += 1;
}
while pos < crate::ported::zle::zle_main::ZLELL.load(std::sync::atomic::Ordering::SeqCst) && { let __c = crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[pos]; (__c.is_alphanumeric()
|| __c == '_') } {
pos += 1;
}
}
WordStyle::Vi => {
if pos < crate::ported::zle::zle_main::ZLELL.load(std::sync::atomic::Ordering::SeqCst) {
let is_word = crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[pos].is_alphanumeric()
|| crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[pos] == '_';
while pos < crate::ported::zle::zle_main::ZLELL.load(std::sync::atomic::Ordering::SeqCst) {
let c = crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[pos];
if c.is_whitespace()
|| ((c.is_alphanumeric() || c == '_') != is_word) {
break;
}
pos += 1;
}
while pos < crate::ported::zle::zle_main::ZLELL.load(std::sync::atomic::Ordering::SeqCst) && crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[pos].is_whitespace() {
pos += 1;
}
}
}
WordStyle::Shell => {
}
WordStyle::BlankDelimited => {
while pos < crate::ported::zle::zle_main::ZLELL.load(std::sync::atomic::Ordering::SeqCst) && !crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[pos].is_whitespace() {
pos += 1;
}
while pos < crate::ported::zle::zle_main::ZLELL.load(std::sync::atomic::Ordering::SeqCst) && crate::ported::zle::zle_main::ZLELINE.lock().unwrap()[pos].is_whitespace() {
pos += 1;
}
}
}
pos
}
#[cfg(test)]
mod tests {
use super::*;
fn line(s: &str) {
crate::ported::zle::zle_main::zle_reset();
*crate::ported::zle::zle_main::ZLELINE.lock().unwrap() = s.chars().collect();
crate::ported::zle::zle_main::ZLELL.store(crate::ported::zle::zle_main::ZLELINE.lock().unwrap().len(), std::sync::atomic::Ordering::SeqCst);
crate::ported::zle::zle_main::ZLECS.store(0, std::sync::atomic::Ordering::SeqCst);
}
#[test]
fn wordclass_dispatch() {
let _g = crate::ported::zle::zle_main::zle_test_setup();
assert_eq!(wordclass(' '), 0);
assert_eq!(wordclass('a'), 1);
assert_eq!(wordclass('_'), 1);
assert_eq!(wordclass('5'), 1);
assert_eq!(wordclass(';'), 2);
}
#[test]
fn forwardword_basic() {
let _g = crate::ported::zle::zle_main::zle_test_setup();
let mut z = line("foo bar baz");
forwardword(&[]);
assert_eq!(crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst), 4);
}
#[test]
fn backwardword_lands_at_word_start() {
let _g = crate::ported::zle::zle_main::zle_test_setup();
let mut z = line("foo bar baz");
crate::ported::zle::zle_main::ZLECS.store(crate::ported::zle::zle_main::ZLELL.load(std::sync::atomic::Ordering::SeqCst), std::sync::atomic::Ordering::SeqCst);
backwardword(&[]);
assert_eq!(crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst), 8);
}
#[test]
fn upcaseword_uppercases_next_word() {
let _g = crate::ported::zle::zle_main::zle_test_setup();
let mut z = line("foo bar");
upcaseword(&[]);
let s: String = crate::ported::zle::zle_main::ZLELINE.lock().unwrap().iter().collect();
assert_eq!(s, "FOO bar");
assert_eq!(crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst), 3); }
#[test]
fn downcaseword_lowercases_next_word() {
let _g = crate::ported::zle::zle_main::zle_test_setup();
let mut z = line("FOO Bar");
downcaseword(&[]);
let s: String = crate::ported::zle::zle_main::ZLELINE.lock().unwrap().iter().collect();
assert_eq!(s, "foo Bar");
}
#[test]
fn capitalizeword_first_only() {
let _g = crate::ported::zle::zle_main::zle_test_setup();
let mut z = line("foo bar");
capitalizeword(&[]);
let s: String = crate::ported::zle::zle_main::ZLELINE.lock().unwrap().iter().collect();
assert_eq!(s, "Foo bar");
}
#[test]
fn deleteword_drops_next_word() {
let _g = crate::ported::zle::zle_main::zle_test_setup();
let mut z = line("foo bar baz");
deleteword(&[]);
let s: String = crate::ported::zle::zle_main::ZLELINE.lock().unwrap().iter().collect();
assert_eq!(s, " bar baz");
assert_eq!(crate::ported::zle::zle_main::ZLECS.load(std::sync::atomic::Ordering::SeqCst), 0);
}
#[test]
fn transposewords_swaps_pair() {
let _g = crate::ported::zle::zle_main::zle_test_setup();
let mut z = line("foo bar");
crate::ported::zle::zle_main::ZLECS.store(5, std::sync::atomic::Ordering::SeqCst); transposewords(&[]);
let s: String = crate::ported::zle::zle_main::ZLELINE.lock().unwrap().iter().collect();
assert_eq!(s, "bar foo");
}
}