<commit_before>package main

import (
	"math"

	"github.com/bcicen/ctop/connector"
	"github.com/bcicen/ctop/container"
	ui "github.com/gizak/termui"
)

var enabledConnectors = map[string]func() connector.Connector{
	"docker": connector.NewDocker,
	"runc":   connector.NewRunc,
}

type GridCursor struct {
	selectedID  string // id of currently selected container
	filtered    container.Containers
	cSource     connector.Connector
	isScrolling bool // toggled when actively scrolling
}

func NewGridCursor(connector string) *GridCursor {
	return &GridCursor{
		cSource: enabledConnectors[connector](),
	}
}

func (gc *GridCursor) Len() int { return len(gc.filtered) }

func (gc *GridCursor) Selected() *container.Container {
	idx := gc.Idx()
	if idx < gc.Len() {
		return gc.filtered[idx]
	}
	return nil
}

// Refresh containers from source
func (gc *GridCursor) RefreshContainers() (lenChanged bool) {
	oldLen := gc.Len()

	// Containers filtered by display bool
	gc.filtered = container.Containers{}
	var cursorVisible bool
	for _, c := range gc.cSource.All() {
		if c.Display {
			if c.Id == gc.selectedID {
				cursorVisible = true
			}
			gc.filtered = append(gc.filtered, c)
		}
	}

	if oldLen != gc.Len() {
		lenChanged = true<commit_msg>update potentially conflicting variable name<commit_after>package main

import (
	"math"

	"github.com/bcicen/ctop/connector"
	"github.com/bcicen/ctop/container"
	ui "github.com/gizak/termui"
)

var enabledConnectors = map[string]func() connector.Connector{
	"docker": connector.NewDocker,
	"runc":   connector.NewRunc,
}

type GridCursor struct {
	selectedID  string // id of currently selected container
	filtered    container.Containers
	cSource     connector.Connector
	isScrolling bool // toggled when actively scrolling
}

func NewGridCursor(connectorName string) *GridCursor {
	return &GridCursor{
		cSource: enabledConnectors[connectorName](),
	}
}

func (gc *GridCursor) Len() int { return len(gc.filtered) }

func (gc *GridCursor) Selected() *container.Container {
	idx := gc.Idx()
	if idx < gc.Len() {
		return gc.filtered[idx]
	}
	return nil
}

// Refresh containers from source
func (gc *GridCursor) RefreshContainers() (lenChanged bool) {
	oldLen := gc.Len()

	// Containers filtered by display bool
	gc.filtered = container.Containers{}
	var cursorVisible bool
	for _, c := range gc.cSource.All() {
		if c.Display {
			if c.Id == gc.selectedID {
				cursorVisible = true
			}
			gc.filtered = append(gc.filtered, c)
		}
	}

	if oldLen != gc.Len() {
		lenChanged = true
{'fraction_non_alphanumeric': 0.11950929956470123, 'fraction_numerical': 0.0, 'mean_word_length': 4.025844930417495, 'pattern_counts': {'":': 4, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3035477', 'n_tokens_mistral': 908, 'n_tokens_neox': 854, 'n_words': 215}