mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-24 17:27:39 +02:00
Initialize various maps
This commit is contained in:
@@ -151,6 +151,9 @@ type ParsedShortcut struct {
|
|||||||
var parsed_shortcut_cache map[string]ParsedShortcut
|
var parsed_shortcut_cache map[string]ParsedShortcut
|
||||||
|
|
||||||
func ParseShortcut(spec string) *ParsedShortcut {
|
func ParseShortcut(spec string) *ParsedShortcut {
|
||||||
|
if parsed_shortcut_cache == nil {
|
||||||
|
parsed_shortcut_cache = make(map[string]ParsedShortcut, 128)
|
||||||
|
}
|
||||||
if val, ok := parsed_shortcut_cache[spec]; ok {
|
if val, ok := parsed_shortcut_cache[spec]; ok {
|
||||||
return &val
|
return &val
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -209,7 +209,7 @@ func (self *Loop) Run() (err error) {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var selector Select
|
selector := CreateSelect(8)
|
||||||
selector.RegisterRead(int(signal_read_file.Fd()))
|
selector.RegisterRead(int(signal_read_file.Fd()))
|
||||||
selector.RegisterRead(tty_fd)
|
selector.RegisterRead(tty_fd)
|
||||||
|
|
||||||
@@ -318,10 +318,10 @@ func (self *Loop) write_to_tty() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *Loop) flush() error {
|
func (self *Loop) flush() error {
|
||||||
var selector Select
|
|
||||||
if self.controlling_term == nil {
|
if self.controlling_term == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
selector := CreateSelect(1)
|
||||||
selector.RegisterWrite(self.controlling_term.Fd())
|
selector.RegisterWrite(self.controlling_term.Fd())
|
||||||
deadline := time.Now().Add(2 * time.Second)
|
deadline := time.Now().Add(2 * time.Second)
|
||||||
for len(self.write_buf) > 0 {
|
for len(self.write_buf) > 0 {
|
||||||
|
|||||||
@@ -13,6 +13,14 @@ type Select struct {
|
|||||||
read_fds, write_fds, err_fds map[int]bool
|
read_fds, write_fds, err_fds map[int]bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func CreateSelect(expected_number_of_fds int) *Select {
|
||||||
|
var ans Select
|
||||||
|
ans.read_fds = make(map[int]bool, expected_number_of_fds)
|
||||||
|
ans.write_fds = make(map[int]bool, expected_number_of_fds)
|
||||||
|
ans.err_fds = make(map[int]bool, expected_number_of_fds)
|
||||||
|
return &ans
|
||||||
|
}
|
||||||
|
|
||||||
func (self *Select) register(fd int, fdset *map[int]bool) {
|
func (self *Select) register(fd int, fdset *map[int]bool) {
|
||||||
(*fdset)[fd] = true
|
(*fdset)[fd] = true
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user