34 lines
727 B
JavaScript
34 lines
727 B
JavaScript
import React, { Component } from 'react'
|
|
import blessed from 'blessed'
|
|
import { render } from 'react-blessed'
|
|
import { Box } from './components'
|
|
|
|
const getDefaultState = () => ({ text: 'Hello, world!' })
|
|
|
|
// Rendering a simple centered box
|
|
class App extends Component {
|
|
constructor() {
|
|
super()
|
|
this.state = getDefaultState()
|
|
}
|
|
render() {
|
|
return <Box {...this.state} />
|
|
}
|
|
}
|
|
|
|
// Creating our screen
|
|
const screen = blessed.screen({
|
|
autoPadding: true,
|
|
smartCSR: true,
|
|
title: 'hello world',
|
|
})
|
|
|
|
// Adding a way to quit the program
|
|
screen.key(['escape', 'q', 'C-c'], () => {
|
|
//callback has access to ch, key
|
|
return process.exit(0)
|
|
})
|
|
|
|
// Rendering the React app using our screen
|
|
render(<App />, screen)
|