Skip to content

How to process grid_line and flush events properly #576

Answered by stefanwatt
stefanwatt asked this question in Q&A
Discussion options

You must be logged in to vote

Answering my own question:
I changed the signature of gridLine:

func (s *Screen) gridLine(gridId int, row int, col int, cells []interface{}) {
	grid, exists := s.Grids[gridId]
	if !exists {
		return
	}

	if row >= grid.Height || col >= grid.Width {
		utils.Log(fmt.Sprintf("Row %d or col %d out of bounds for grid %d (max: %d,%d)",
			row, col, gridId, grid.Height-1, grid.Width-1))
		return
	}
	currentCol := col
	for _, cell := range cells {
		cellData, ok := cell.([]interface{})
		if !ok || len(cellData) == 0 {
			continue
		}

		char := cellData[0].(string)
		repeat := 1
		if len(cellData) > 2 {
			repeat = utils.ReflectToInt(cellData[2])
		}

		hl := 0
		if len(cellData) > 1 {
			hl = ut…

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by stefanwatt
Comment options

You must be logged in to vote
1 reply
@stefanwatt
Comment options

Comment options

You must be logged in to vote
2 replies
@stefanwatt
Comment options

@akiyosi
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants