| 15 | }; |
| 16 | |
| 17 | export async function getContextForConfig( |
| 18 | config: Config, |
| 19 | chalk: ChalkInstance, |
| 20 | screenWidth: number |
| 21 | ): Promise<Context> { |
| 22 | const SCREEN_WIDTH = screenWidth; |
| 23 | |
| 24 | const HORIZONTAL_SEPARATOR = T() |
| 25 | .fillWidth(SCREEN_WIDTH, '─') |
| 26 | .addSpan(0, SCREEN_WIDTH, config.BORDER_COLOR); |
| 27 | |
| 28 | let HIGHLIGHTER = undefined; |
| 29 | if (config.SYNTAX_HIGHLIGHTING_THEME) { |
| 30 | HIGHLIGHTER = await shiki.createHighlighter({ |
| 31 | themes: [config.SYNTAX_HIGHLIGHTING_THEME], |
| 32 | langs: [], |
| 33 | }); |
| 34 | } |
| 35 | return { |
| 36 | ...config, |
| 37 | CHALK: chalk, |
| 38 | SCREEN_WIDTH, |
| 39 | HORIZONTAL_SEPARATOR, |
| 40 | HIGHLIGHTER, |
| 41 | }; |
| 42 | } |