@@ -21,6 +21,7 @@ use helix_view::{
2121    graphics:: { Color ,  CursorKind ,  Modifier ,  Rect ,  Style } , 
2222    input:: { KeyEvent ,  MouseButton ,  MouseEvent ,  MouseEventKind } , 
2323    keyboard:: { KeyCode ,  KeyModifiers } , 
24+     theme:: ThemeKey , 
2425    Document ,  Editor ,  Theme ,  View , 
2526} ; 
2627use  std:: { borrow:: Cow ,  path:: PathBuf } ; 
@@ -107,7 +108,7 @@ impl EditorView {
107108                            area. width , 
108109                            1 , 
109110                        ) , 
110-                         theme. get ( "ui.highlight" ) , 
111+                         theme. get ( ThemeKey :: UiHighlight ) , 
111112                    ) ; 
112113                } 
113114            } 
@@ -153,7 +154,7 @@ impl EditorView {
153154        // if we're not at the edge of the screen, draw a right border 
154155        if  viewport. right ( )  != view. area . right ( )  { 
155156            let  x = area. right ( ) ; 
156-             let  border_style = theme. get ( "ui.window" ) ; 
157+             let  border_style = theme. get ( ThemeKey :: UiWindow ) ; 
157158            for  y in  area. top ( ) ..area. bottom ( )  { 
158159                surface[ ( x,  y) ] 
159160                    . set_symbol ( tui:: symbols:: line:: VERTICAL ) 
@@ -185,7 +186,7 @@ impl EditorView {
185186    )  { 
186187        let  editor_rulers = & editor. config ( ) . rulers ; 
187188        let  ruler_theme = theme
188-             . try_get ( "ui.virtual.ruler" ) 
189+             . try_get ( ThemeKey :: UiVirtualRuler ) 
189190            . unwrap_or_else ( || Style :: default ( ) . bg ( Color :: Red ) ) ; 
190191
191192        let  rulers = doc
@@ -268,20 +269,20 @@ impl EditorView {
268269            theme
269270            . find_scope_index ( scope) 
270271            // get one of the themes below as fallback values 
271-             . or_else ( || theme. find_scope_index ( "diagnostic" ) ) 
272-             . or_else ( || theme. find_scope_index ( "ui.cursor" ) ) 
273-             . or_else ( || theme. find_scope_index ( "ui.selection" ) ) 
272+             . or_else ( || theme. find_scope_index ( ThemeKey :: Diagnostic ) ) 
273+             . or_else ( || theme. find_scope_index ( ThemeKey :: UiCursor ) ) 
274+             . or_else ( || theme. find_scope_index ( ThemeKey :: UiSelection ) ) 
274275            . expect ( 
275276                "at least one of the following scopes must be defined in the theme: `diagnostic`, `ui.cursor`, or `ui.selection`" , 
276277            ) 
277278        } ; 
278279
279280        // basically just queries the theme color defined in the config 
280-         let  hint = get_scope_of ( "diagnostic.hint" ) ; 
281-         let  info = get_scope_of ( "diagnostic.info" ) ; 
282-         let  warning = get_scope_of ( "diagnostic.warning" ) ; 
283-         let  error = get_scope_of ( "diagnostic.error" ) ; 
284-         let  r#default = get_scope_of ( "diagnostic" ) ;  // this is a bit redundant but should be fine 
281+         let  hint = get_scope_of ( ThemeKey :: DiagnosticHint ) ; 
282+         let  info = get_scope_of ( ThemeKey :: DiagnosticInfo ) ; 
283+         let  warning = get_scope_of ( ThemeKey :: DiagnosticWarning ) ; 
284+         let  error = get_scope_of ( ThemeKey :: DiagnosticError ) ; 
285+         let  r#default = get_scope_of ( ThemeKey :: Diagnostic ) ;  // this is a bit redundant but should be fine 
285286
286287        doc. diagnostics ( ) 
287288            . iter ( ) 
@@ -317,24 +318,24 @@ impl EditorView {
317318        let  cursor_is_block = cursorkind == CursorKind :: Block ; 
318319
319320        let  selection_scope = theme
320-             . find_scope_index ( "ui.selection" ) 
321+             . find_scope_index ( ThemeKey :: UiSelection ) 
321322            . expect ( "could not find `ui.selection` scope in the theme!" ) ; 
322323        let  base_cursor_scope = theme
323-             . find_scope_index ( "ui.cursor" ) 
324+             . find_scope_index ( ThemeKey :: UiCursor ) 
324325            . unwrap_or ( selection_scope) ; 
325326
326327        let  cursor_scope = match  mode { 
327-             Mode :: Insert  => theme. find_scope_index ( "ui.cursor.insert" ) , 
328-             Mode :: Select  => theme. find_scope_index ( "ui.cursor.select" ) , 
328+             Mode :: Insert  => theme. find_scope_index ( ThemeKey :: UiCursorInsert ) , 
329+             Mode :: Select  => theme. find_scope_index ( ThemeKey :: UiCursorSelect ) , 
329330            Mode :: Normal  => Some ( base_cursor_scope) , 
330331        } 
331332        . unwrap_or ( base_cursor_scope) ; 
332333
333334        let  primary_cursor_scope = theme
334-             . find_scope_index ( "ui.cursor.primary" ) 
335+             . find_scope_index ( ThemeKey :: UiCursorPrimary ) 
335336            . unwrap_or ( cursor_scope) ; 
336337        let  primary_selection_scope = theme
337-             . find_scope_index ( "ui.selection.primary" ) 
338+             . find_scope_index ( ThemeKey :: UiSelectionPrimary ) 
338339            . unwrap_or ( selection_scope) ; 
339340
340341        let  mut  spans:  Vec < ( usize ,  std:: ops:: Range < usize > ) >  = Vec :: new ( ) ; 
@@ -418,17 +419,17 @@ impl EditorView {
418419        } ; 
419420        let  indent_guide_char = config. indent_guides . character . to_string ( ) ; 
420421
421-         let  text_style = theme. get ( "ui.text" ) ; 
422-         let  whitespace_style = theme. get ( "ui.virtual.whitespace" ) ; 
422+         let  text_style = theme. get ( ThemeKey :: UiText ) ; 
423+         let  whitespace_style = theme. get ( ThemeKey :: UiVirtualWhitespace ) ; 
423424
424425        let  mut  is_in_indent_area = true ; 
425426        let  mut  last_line_indent_level = 0 ; 
426427
427428        // use whitespace style as fallback for indent-guide 
428429        let  indent_guide_style = text_style. patch ( 
429430            theme
430-                 . try_get ( "ui.virtual.indent-guide" ) 
431-                 . unwrap_or_else ( || theme. get ( "ui.virtual.whitespace" ) ) , 
431+                 . try_get ( ThemeKey :: UiVirtualIndentguide ) 
432+                 . unwrap_or_else ( || theme. get ( ThemeKey :: UiVirtualWhitespace ) ) , 
432433        ) ; 
433434
434435        let  draw_indent_guides = |indent_level,  line,  surface :  & mut  Surface | { 
@@ -606,7 +607,7 @@ impl EditorView {
606607                if  ( pos. col  as  u16 )  < viewport. width  + view. offset . col  as  u16 
607608                    && pos. col  >= view. offset . col 
608609                { 
609-                     let  style = theme. try_get ( "ui.cursor.match" ) . unwrap_or_else ( || { 
610+                     let  style = theme. try_get ( ThemeKey :: UiCursorMatch ) . unwrap_or_else ( || { 
610611                        Style :: default ( ) 
611612                            . add_modifier ( Modifier :: REVERSED ) 
612613                            . add_modifier ( Modifier :: DIM ) 
@@ -626,19 +627,19 @@ impl EditorView {
626627            viewport, 
627628            editor
628629                . theme 
629-                 . try_get ( "ui.bufferline.background" ) 
630-                 . unwrap_or_else ( || editor. theme . get ( "ui.statusline" ) ) , 
630+                 . try_get ( ThemeKey :: UiBufferlineBackground ) 
631+                 . unwrap_or_else ( || editor. theme . get ( ThemeKey :: UiStatusline ) ) , 
631632        ) ; 
632633
633634        let  bufferline_active = editor
634635            . theme 
635-             . try_get ( "ui.bufferline.active" ) 
636-             . unwrap_or_else ( || editor. theme . get ( "ui.statusline.active" ) ) ; 
636+             . try_get ( ThemeKey :: UiBufferlineActive ) 
637+             . unwrap_or_else ( || editor. theme . get ( ThemeKey :: UiStatuslineActive ) ) ; 
637638
638639        let  bufferline_inactive = editor
639640            . theme 
640-             . try_get ( "ui.bufferline" ) 
641-             . unwrap_or_else ( || editor. theme . get ( "ui.statusline.inactive" ) ) ; 
641+             . try_get ( ThemeKey :: UiBufferline ) 
642+             . unwrap_or_else ( || editor. theme . get ( ThemeKey :: UiStatuslineInactive ) ) ; 
642643
643644        let  mut  x = viewport. x ; 
644645        let  current_doc = view ! ( editor) . doc ; 
@@ -695,7 +696,7 @@ impl EditorView {
695696
696697        let  mut  offset = 0 ; 
697698
698-         let  gutter_style = theme. get ( "ui.gutter" ) ; 
699+         let  gutter_style = theme. get ( ThemeKey :: UiGutter ) ; 
699700
700701        // avoid lots of small allocations by reusing a text buffer for each line 
701702        let  mut  text = String :: with_capacity ( 8 ) ; 
@@ -752,13 +753,13 @@ impl EditorView {
752753            diagnostic. range . start  <= cursor && diagnostic. range . end  >= cursor
753754        } ) ; 
754755
755-         let  warning = theme. get ( "warning" ) ; 
756-         let  error = theme. get ( "error" ) ; 
757-         let  info = theme. get ( "info" ) ; 
758-         let  hint = theme. get ( "hint" ) ; 
756+         let  warning = theme. get ( ThemeKey :: Warning ) ; 
757+         let  error = theme. get ( ThemeKey :: Error ) ; 
758+         let  info = theme. get ( ThemeKey :: Info ) ; 
759+         let  hint = theme. get ( ThemeKey :: Hint ) ; 
759760
760761        let  mut  lines = Vec :: new ( ) ; 
761-         let  background_style = theme. get ( "ui.background" ) ; 
762+         let  background_style = theme. get ( ThemeKey :: UiBackground ) ; 
762763        for  diagnostic in  diagnostics { 
763764            let  style = Style :: reset ( ) 
764765                . patch ( background_style) 
@@ -802,8 +803,8 @@ impl EditorView {
802803            . map ( |range| range. cursor_line ( text) ) 
803804            . collect ( ) ; 
804805
805-         let  primary_style = theme. get ( "ui.cursorline.primary" ) ; 
806-         let  secondary_style = theme. get ( "ui.cursorline.secondary" ) ; 
806+         let  primary_style = theme. get ( ThemeKey :: UiCursorlinePrimary ) ; 
807+         let  secondary_style = theme. get ( ThemeKey :: UiCursorlineSecondary ) ; 
807808
808809        for  line in  view. offset . row ..( last_line + 1 )  { 
809810            let  area = Rect :: new ( 
@@ -1342,7 +1343,7 @@ impl Component for EditorView {
13421343
13431344    fn  render ( & mut  self ,  area :  Rect ,  surface :  & mut  Surface ,  cx :  & mut  Context )  { 
13441345        // clear with background color 
1345-         surface. set_style ( area,  cx. editor . theme . get ( "ui.background" ) ) ; 
1346+         surface. set_style ( area,  cx. editor . theme . get ( ThemeKey :: UiBackground ) ) ; 
13461347        let  config = cx. editor . config ( ) ; 
13471348
13481349        // check if bufferline should be rendered 
@@ -1386,9 +1387,9 @@ impl Component for EditorView {
13861387            status_msg_width = status_msg. width ( ) ; 
13871388            use  helix_view:: editor:: Severity ; 
13881389            let  style = if  * severity == Severity :: Error  { 
1389-                 cx. editor . theme . get ( "error" ) 
1390+                 cx. editor . theme . get ( ThemeKey :: Error ) 
13901391            }  else  { 
1391-                 cx. editor . theme . get ( "ui.text" ) 
1392+                 cx. editor . theme . get ( ThemeKey :: UiText ) 
13921393            } ; 
13931394
13941395            surface. set_string ( 
@@ -1410,7 +1411,7 @@ impl Component for EditorView {
14101411            if  let  Some ( pseudo_pending)  = & cx. editor . pseudo_pending  { 
14111412                disp. push_str ( pseudo_pending. as_str ( ) ) 
14121413            } 
1413-             let  style = cx. editor . theme . get ( "ui.text" ) ; 
1414+             let  style = cx. editor . theme . get ( ThemeKey :: UiText ) ; 
14141415            let  macro_width = if  cx. editor . macro_recording . is_some ( )  { 
14151416                3 
14161417            }  else  { 
0 commit comments