ironwork_rt/picture.rs
1//! The symbols of an edited PICTURE.
2
3/// One position of an edited PICTURE.
4#[derive(Clone, Copy, Debug, PartialEq, Eq)]
5pub enum Sym {
6 Nine,
7 Z,
8 Star,
9 /// The first symbol of a floating insertion string: a sign or currency position, not a digit.
10 FloatLead(char),
11 /// A later symbol of a floating insertion string: a digit position.
12 Float(char),
13 /// A fixed + or -.
14 Sign(char),
15 Currency,
16 Cr,
17 Db,
18 Point,
19 /// V: the decimal point, occupying no position.
20 Implied,
21 /// B (as a space), 0, / or a comma.
22 Insert(char),
23 /// X, A or 9 in an alphanumeric-edited PICTURE.
24 Char,
25}
26
27impl Sym {
28 pub fn is_digit(&self) -> bool {
29 matches!(self, Sym::Nine | Sym::Z | Sym::Star | Sym::Float(_))
30 }
31
32 /// Character positions the symbol occupies in the edited item.
33 pub fn width(&self) -> usize {
34 match self {
35 Sym::Implied => 0,
36 Sym::Cr | Sym::Db => 2,
37 _ => 1,
38 }
39 }
40}