pub fn move_notes() {
    pp!("From To (n1 n2) | ");
    p!("Or Range (4-10 2)");
    pp!("Or Up (4 up 2) | ");
    p!("Or Down (4 down 2)");

    let ans = ask_string("Move", "", true);
    if ans.is_empty() {
        return;
    }
    let n1;
    let mut n2;
    let max = g_get_notes_length();

    // Get the range to move
    if ans.contains('-') {
        if ans.matches('-').count() > 1 {
            return;
        }
        let mut split = ans.split('-').map(|n| n.trim());
        n1 = parse_note_ans(split.next().unwrap_or("0"));
        let right_side = split.next().unwrap_or("nothing");
        let mut split_right = right_side.split_whitespace().map(|n| n.trim());
        n2 = parse_note_ans(split_right.next().unwrap_or("0"));
        if n1 == 0 || n2 == 0 {
            return;
        }
        if n2 > max {
            n2 = max
        }
        if n1 >= n2 {
            return;
        }
    } else {
        let mut split = ans.split_whitespace().map(|n| n.trim());
        n1 = parse_note_ans(split.next().unwrap_or("0"));
        if n1 == 0 {
            return;
        }
        if !check_line_exists(n1) {
            return;
        }
        n2 = n1;
    }

    // Get the destination index
    let dest = if ans.contains("up") {
        let steps = ans
            .split("up")
            .last()
            .unwrap_or("0")
            .trim()
            .parse::<usize>()
            .unwrap_or(0);

        if steps == 0 {
            return;
        }
        if (n1 as isize - steps as isize) < 1 {
            return;
        }
        n1 - steps
    } else if ans.contains("down") {
        let steps = ans
            .split("down")
            .last()
            .unwrap_or("0")
            .trim()
            .parse::<usize>()
            .unwrap_or(0);

        if steps == 0 {
            return;
        }
        if n2 + steps > max {
            return;
        }
        n2 + steps
    } else {
        let split = ans.split_whitespace().map(|n| n.trim());
        parse_note_ans(split.last().unwrap_or("0"))
    };

    if !check_line_exists(dest) {
        return;
    }
    if dest >= n1 && dest <= n2 {
        return;
    }
    if n1 == dest {
        return;
    }

    move_lines(n1, n2, dest);
    fix_last_edit_after_move(n1, n2, dest);
    show_page(get_note_page(dest));
}
// Asks for a range or single note
// and a destination. The moves it
Asks for a range or single note
and a destination. The moves it
Asks for a range or single note and a destination . The moves it
pub fn move_notes() {
    pp!("From To (n1 n2) | ");
    p!("Or Range (4-10 2)");
    pp!("Or Up (4 up 2) | ");
    p!("Or Down (4 down 2)");
    let ans = ask_string("Move", "", true);
    if ans.is_empty() {
        return;
    }
    let n1;
    let mut n2;
    let max = g_get_notes_length();
    // Get the range to move
    if ans.contains('-') {
        if ans.matches('-').count() > 1 {
            return;
        }
        let mut split = ans.split('-').map(|n| n.trim());
        n1 = parse_note_ans(split.next().unwrap_or("0"));
        let right_side = split.next().unwrap_or("nothing");
        let mut split_right = right_side.split_whitespace().map(|n| n.trim());
        n2 = parse_note_ans(split_right.next().unwrap_or("0"));
        if n1 == 0 || n2 == 0 {
            return;
        }
        if n2 > max {
            n2 = max
        }
        if n1 >= n2 {
            return;
        }
    } else {
        let mut split = ans.split_whitespace().map(|n| n.trim());
        n1 = parse_note_ans(split.next().unwrap_or("0"));
        if n1 == 0 {
            return;
        }
        if !check_line_exists(n1) {
            return;
        }
        n2 = n1;
    }
    // Get the destination index
    let dest = if ans.contains("up") {
        let steps = ans
            .split("up")
            .last()
            .unwrap_or("0")
            .trim()
            .parse::<usize>()
            .unwrap_or(0);
        if steps == 0 {
            return;
        }
        if (n1 as isize - steps as isize) < 1 {
            return;
        }
        n1 - steps
    } else if ans.contains("down") {
        let steps = ans
            .split("down")
            .last()
            .unwrap_or("0")
            .trim()
            .parse::<usize>()
            .unwrap_or(0);
        if steps == 0 {
            return;
        }
        if n2 + steps > max {
            return;
        }
        n2 + steps
    } else {
        let split = ans.split_whitespace().map(|n| n.trim());
        parse_note_ans(split.last().unwrap_or("0"))
    };
    if !check_line_exists(dest) {
        return;
    }
    if dest >= n1 && dest <= n2 {
        return;
    }
    if n1 == dest {
        return;
    }
    move_lines(n1, n2, dest);
    fix_last_edit_after_move(n1, n2, dest);
    show_page(get_note_page(dest));
}
pub fn move_notes ( ) { pp ! ( " " ) ; p ! ( " " ) ; pp ! ( " " ) ; p ! ( " " ) ; let ans = ask_string ( " " , " " , true ) ; if ans . is_empty ( ) { return ; } let n1 ; let mut n2 ; let max = g_get_notes_length ( ) ; // Get the range to move if ans . contains ( '-' ) { if ans . matches ( '-' ) . count ( ) > 1 { return ; } let mut split = ans . split ( '-' ) . map ( | n | n . trim ( ) ) ; n1 = parse_note_ans ( split . next ( ) . unwrap_or ( " " ) ) ; let right_side = split . next ( ) . unwrap_or ( " " ) ; let mut split_right = right_side . split_whitespace ( ) . map ( | n | n . trim ( ) ) ; n2 = parse_note_ans ( split_right . next ( ) . unwrap_or ( " " ) ) ; if n1 == 0 || n2 == 0 { return ; } if n2 > max { n2 = max } if n1 >= n2 { return ; } } else { let mut split = ans . split_whitespace ( ) . map ( | n | n . trim ( ) ) ; n1 = parse_note_ans ( split . next ( ) . unwrap_or ( " " ) ) ; if n1 == 0 { return ; } if ! check_line_exists ( n1 ) { return ; } n2 = n1 ; } // Get the destination index let dest = if ans . contains ( " " ) { let steps = ans . split ( " " ) . last ( ) . unwrap_or ( " " ) . trim ( ) . parse :: < usize > ( ) . unwrap_or ( 0 ) ; if steps == 0 { return ; } if ( n1 as isize - steps as isize ) < 1 { return ; } n1 - steps } else if ans . contains ( " " ) { let steps = ans . split ( " " ) . last ( ) . unwrap_or ( " " ) . trim ( ) . parse :: < usize > ( ) . unwrap_or ( 0 ) ; if steps == 0 { return ; } if n2 + steps > max { return ; } n2 + steps } else { let split = ans . split_whitespace ( ) . map ( | n | n . trim ( ) ) ; parse_note_ans ( split . last ( ) . unwrap_or ( " " ) ) } ; if ! check_line_exists ( dest ) { return ; } if dest >= n1 && dest <= n2 { return ; } if n1 == dest { return ; } move_lines ( n1 , n2 , dest ) ; fix_last_edit_after_move ( n1 , n2 , dest ) ; show_page ( get_note_page ( dest ) ) ; }
Asks for a range or single note
and a destination.
Asks for a range or single note and a destination .