@@ -3,11 +3,9 @@ use ratatui::{Frame, layout::Rect, style::Style, text::Line};
33
44use crate :: screen:: EventResult ;
55
6- use super :: {
7- context:: TableContext ,
8- mode:: {
9- Direction , EditorIntent , EditorView , FooterLine , Mode , ModeKind , ModeResult , Selection ,
10- } ,
6+ use super :: mode:: {
7+ Direction , EditorIntent , EditorReadModel , EditorView , FooterLine , Mode , ModeKind , ModeResult ,
8+ Selection ,
119} ;
1210
1311/// 默认模式 —— 光标导航、单元格删除、进入编辑。
@@ -103,55 +101,55 @@ impl Mode for NavigationMode {
103101 }
104102 }
105103
106- fn render ( & self , _frame : & mut Frame , area : Rect , _ctx : & TableContext ) -> Rect {
104+ fn render ( & self , _frame : & mut Frame , area : Rect , _read : EditorReadModel < ' _ > ) -> Rect {
107105 area
108106 }
109107
110- fn footer ( & self , ctx : & TableContext ) -> FooterLine {
108+ fn footer ( & self , read : EditorReadModel < ' _ > ) -> FooterLine {
111109 use ratatui:: text:: Span ;
112- let hint = if let Some ( stats) = ctx . selection_stats ( ) {
110+ let hint = if let Some ( stats) = read . selection_stats {
113111 Line :: from ( vec ! [
114- Span :: styled( "平均值=" , Style :: default ( ) . fg( ctx . theme. accent) ) ,
112+ Span :: styled( "平均值=" , Style :: default ( ) . fg( read . theme. accent) ) ,
115113 Span :: styled(
116114 format!( " {}" , format_number( stats. average) ) ,
117- Style :: default ( ) . fg( ctx . theme. text_dim) ,
115+ Style :: default ( ) . fg( read . theme. text_dim) ,
118116 ) ,
119- Span :: styled( " " , Style :: default ( ) . fg( ctx . theme. text_dim) ) ,
120- Span :: styled( "求和=" , Style :: default ( ) . fg( ctx . theme. accent) ) ,
117+ Span :: styled( " " , Style :: default ( ) . fg( read . theme. text_dim) ) ,
118+ Span :: styled( "求和=" , Style :: default ( ) . fg( read . theme. accent) ) ,
121119 Span :: styled(
122120 format!( " {}" , format_number( stats. sum) ) ,
123- Style :: default ( ) . fg( ctx . theme. text_dim) ,
121+ Style :: default ( ) . fg( read . theme. text_dim) ,
124122 ) ,
125- Span :: styled( " " , Style :: default ( ) . fg( ctx . theme. text_dim) ) ,
126- Span :: styled( "计数=" , Style :: default ( ) . fg( ctx . theme. accent) ) ,
123+ Span :: styled( " " , Style :: default ( ) . fg( read . theme. text_dim) ) ,
124+ Span :: styled( "计数=" , Style :: default ( ) . fg( read . theme. accent) ) ,
127125 Span :: styled(
128126 format!( " {}" , stats. count) ,
129- Style :: default ( ) . fg( ctx . theme. text_dim) ,
127+ Style :: default ( ) . fg( read . theme. text_dim) ,
130128 ) ,
131129 ] )
132130 } else {
133131 Line :: from ( vec ! [
134- Span :: styled( "Ctrl+S" , Style :: default ( ) . fg( ctx . theme. accent) ) ,
135- Span :: styled( " 保存" , Style :: default ( ) . fg( ctx . theme. text_dim) ) ,
136- Span :: styled( " " , Style :: default ( ) . fg( ctx . theme. text_dim) ) ,
137- Span :: styled( "Ctrl+P" , Style :: default ( ) . fg( ctx . theme. accent) ) ,
138- Span :: styled( " 菜单" , Style :: default ( ) . fg( ctx . theme. text_dim) ) ,
139- Span :: styled( " " , Style :: default ( ) . fg( ctx . theme. text_dim) ) ,
140- Span :: styled( "Enter" , Style :: default ( ) . fg( ctx . theme. accent) ) ,
141- Span :: styled( " 编辑" , Style :: default ( ) . fg( ctx . theme. text_dim) ) ,
132+ Span :: styled( "Ctrl+S" , Style :: default ( ) . fg( read . theme. accent) ) ,
133+ Span :: styled( " 保存" , Style :: default ( ) . fg( read . theme. text_dim) ) ,
134+ Span :: styled( " " , Style :: default ( ) . fg( read . theme. text_dim) ) ,
135+ Span :: styled( "Ctrl+P" , Style :: default ( ) . fg( read . theme. accent) ) ,
136+ Span :: styled( " 菜单" , Style :: default ( ) . fg( read . theme. text_dim) ) ,
137+ Span :: styled( " " , Style :: default ( ) . fg( read . theme. text_dim) ) ,
138+ Span :: styled( "Enter" , Style :: default ( ) . fg( read . theme. accent) ) ,
139+ Span :: styled( " 编辑" , Style :: default ( ) . fg( read . theme. text_dim) ) ,
142140 ] )
143141 } ;
144142
145143 FooterLine {
146144 hint : Some ( hint) ,
147145 status : Some ( Line :: from ( vec ! [
148- Span :: styled( "[" , Style :: default ( ) . fg( ctx . theme. text_dim) ) ,
146+ Span :: styled( "[" , Style :: default ( ) . fg( read . theme. text_dim) ) ,
149147 Span :: styled(
150- ctx . cursor( ) . display( ) ,
151- Style :: default ( ) . fg( ctx . theme. accent) ,
148+ read . viewport . cursor( ) . display( ) ,
149+ Style :: default ( ) . fg( read . theme. accent) ,
152150 ) ,
153- Span :: styled( ", 光标模式" , Style :: default ( ) . fg( ctx . theme. text_dim) ) ,
154- Span :: styled( "]" , Style :: default ( ) . fg( ctx . theme. text_dim) ) ,
151+ Span :: styled( ", 光标模式" , Style :: default ( ) . fg( read . theme. text_dim) ) ,
152+ Span :: styled( "]" , Style :: default ( ) . fg( read . theme. text_dim) ) ,
155153 ] ) ) ,
156154 }
157155 }
0 commit comments