1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
use fmt;
/// Represents spacing around rectangular areas.
///
/// `Margin` defines the horizontal and vertical spacing that should be applied around a rectangular
/// area. It's commonly used with [`Layout`](crate::layout::Layout) to add space between the
/// layout's boundaries and its contents, or with [`Rect::inner`](crate::layout::Rect::inner) and
/// [`Rect::outer`](crate::layout::Rect::outer) to create padded areas.
///
/// The margin values represent the number of character cells to add on each side. For horizontal
/// margin, the space is applied to both the left and right sides. For vertical margin, the space
/// is applied to both the top and bottom sides.
///
/// # Construction
///
/// - [`new`](Self::new) - Create a new margin with horizontal and vertical spacing
/// - [`default`](Default::default) - Create with zero margin
///
/// # Examples
///
/// ```rust
/// use ratatui_core::layout::{Constraint, Layout, Margin, Rect};
///
/// // Create a margin of 2 cells horizontally and 1 cell vertically
/// let margin = Margin::new(2, 1);
///
/// // Apply directly to a rectangle
/// let area = Rect::new(0, 0, 80, 24);
/// let inner_area = area.inner(margin);
///
/// // Or use with a layout (which only accepts uniform margins)
/// let layout = Layout::vertical([Constraint::Fill(1)]).margin(2);
/// ```
///
/// For comprehensive layout documentation and examples, see the [`layout`](crate::layout) module.