本文整理汇总了Golang中github.com/limetext/lime/backend.KeyPress类的典型用法代码示例。如果您正苦于以下问题:Golang KeyPress类的具体用法?Golang KeyPress怎么用?Golang KeyPress使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KeyPress类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: key
func (t *tbfe) key(w http.ResponseWriter, req *http.Request) {
log4go.Debug("key: %s", req)
kc := req.FormValue("keyCode")
var kp backend.KeyPress
v, _ := strconv.ParseInt(kc, 10, 32)
if req.FormValue("altKey") == "true" {
kp.Alt = true
}
if req.FormValue("ctrlKey") == "true" {
kp.Ctrl = true
}
if req.FormValue("metaKey") == "true" {
kp.Super = true
}
if req.FormValue("shiftKey") == "true" {
kp.Shift = true
}
if !kp.Shift {
v = int64(unicode.ToLower(rune(v)))
}
kp.Key = backend.Key(v)
backend.GetEditor().HandleInput(kp)
}
示例2: loop
func (t *tbfe) loop() {
var (
ed = t.setupEditor()
c = ed.Console()
w = ed.NewWindow()
v = createNewView("main.go", w)
sel = v.Sel()
)
t.settings = getSettings(v)
c.Buffer().AddCallback(t.scroll)
t.setupCallbacks(v)
loadTextMateScheme()
setColorMode()
setSchemeSettings()
sel.Clear()
sel.Add(Region{0, 0})
evchan := make(chan termbox.Event, 32)
defer func() {
close(evchan)
fmt.Println(util.Prof)
}()
go func() {
for {
evchan <- termbox.PollEvent()
}
}()
{
w, h := termbox.Size()
t.lock.Lock()
t.layout[v] = layout{0, 0, w, h - console_height - 1, Region{}, 0}
t.layout[c] = layout{0, h - console_height + 1, w, console_height - 5, Region{}, 0}
t.lock.Unlock()
t.Show(v, Region{1, 1})
}
t.Show(v, Region{100, 100})
t.Show(v, Region{1, 1})
go func() {
ed.Init()
sublime.Init()
}()
for {
p := util.Prof.Enter("mainloop")
blink_phase := time.Second
if p, ok := ed.Settings().Get("caret_blink_phase", 1.0).(float64); ok {
blink_phase = time.Duration(float64(time.Second) * p)
}
// Divided by two since we're only doing a simple toggle blink
timer := time.NewTimer(blink_phase / 2)
select {
case ev := <-evchan:
mp := util.Prof.Enter("evchan")
limit := 3
loop:
switch ev.Type {
case termbox.EventError:
log4go.Debug("error occured")
return
case termbox.EventKey:
var kp backend.KeyPress
if ev.Ch != 0 {
kp.Key = backend.Key(ev.Ch)
} else if v2, ok := lut[ev.Key]; ok {
kp = v2
} else {
break
}
if ev.Key == termbox.KeyCtrlQ {
return
}
ed.HandleInput(kp)
blink = false
}
if len(evchan) > 0 {
limit--
ev = <-evchan
goto loop
}
mp.Exit()
case <-timer.C:
// TODO(q): Shouldn't redraw if blink is disabled...
blink = !blink
t.render()
}
timer.Stop()
p.Exit()
}
}
示例3: loop
//.........这里部分代码省略.........
}
}()
{
w, h := termbox.Size()
t.lock.Lock()
if *showConsole {
t.layout[v] = layout{0, 0, w, h - *consoleHeight - 4, Region{}, 0}
t.layout[c] = layout{0, h - *consoleHeight - 2, w, *consoleHeight - 1, Region{}, 0}
} else {
t.layout[v] = layout{0, 0, w, h - 3, Region{}, 0}
}
t.lock.Unlock()
t.Show(v, Region{1, 1})
}
t.Show(v, Region{100, 100})
t.Show(v, Region{1, 1})
go func() {
ed.Init()
sublime.Init()
}()
for {
p := util.Prof.Enter("mainloop")
blink_phase := time.Second
if p, ok := ed.Settings().Get("caret_blink_phase", 1.0).(float64); ok {
blink_phase = time.Duration(float64(time.Second) * p)
}
// Divided by two since we're only doing a simple toggle blink
timer := time.NewTimer(blink_phase / 2)
select {
case ev := <-evchan:
mp := util.Prof.Enter("evchan")
limit := 3
loop:
switch ev.Type {
case termbox.EventError:
log4go.Debug("error occured")
return
case termbox.EventResize:
// We have to resize our layouts...
// There is currently duplicate code for calculating the layout:
// during initialization (above), and here. Not nice
if *showConsole {
view_layout := t.layout[v]
view_layout.height = ev.Height - *consoleHeight - 4
view_layout.width = ev.Width
console_layout := t.layout[c]
console_layout.y = ev.Height - *consoleHeight - 2
console_layout.width = ev.Width
t.layout[v] = view_layout
t.layout[c] = console_layout
} else {
view_layout := t.layout[v]
view_layout.height = ev.Height - 3
view_layout.width = ev.Width
t.layout[v] = view_layout
}
// Ensure that the new visible region is recalculated
t.Show(v, t.VisibleRegion(v))
case termbox.EventKey:
var kp backend.KeyPress
if ev.Ch != 0 {
kp.Key = backend.Key(ev.Ch)
} else if v2, ok := lut[ev.Key]; ok {
kp = v2
} else {
break
}
if ev.Key == termbox.KeyCtrlQ {
return
}
ed.HandleInput(kp)
blink = false
}
if len(evchan) > 0 {
limit--
ev = <-evchan
goto loop
}
mp.Exit()
case <-timer.C:
// TODO(q): Shouldn't redraw if blink is disabled...
blink = !blink
t.render()
}
timer.Stop()
p.Exit()
}
}
示例4: loop
func (t *tbfe) loop() {
var (
ed = t.setupEditor()
c = ed.Console()
w = ed.NewWindow()
v *backend.View
)
// Assuming that all extra arguments are files
if files := flag.Args(); len(files) > 0 {
for _, file := range files {
v = createNewView(file, w)
}
} else {
v = w.NewFile()
}
t.settings = getSettings(v)
c.Buffer().AddCallback(t.scroll)
t.setupCallbacks(v)
path := "../../3rdparty/bundles/TextMate-Themes/GlitterBomb.tmTheme"
if sc, err := textmate.LoadTheme(path); err != nil {
log4go.Error(err)
return
} else {
scheme = sc
}
setColorMode()
setSchemeSettings()
evchan := make(chan termbox.Event, 32)
defer func() {
close(evchan)
fmt.Println(util.Prof)
}()
go func() {
for {
evchan <- termbox.PollEvent()
}
}()
{
w, h := termbox.Size()
t.lock.Lock()
if *showConsole {
t.layout[v] = layout{0, 0, w, h - *consoleHeight - 4, Region{}, 0}
t.layout[c] = layout{0, h - *consoleHeight - 2, w, *consoleHeight - 1, Region{}, 0}
} else {
t.layout[v] = layout{0, 0, w, h - 3, Region{}, 0}
}
t.lock.Unlock()
t.Show(v, Region{1, 1})
}
t.Show(v, Region{100, 100})
t.Show(v, Region{1, 1})
go func() {
ed.Init()
sublime.Init()
}()
for {
p := util.Prof.Enter("mainloop")
blink_phase := time.Second
if p, ok := ed.Settings().Get("caret_blink_phase", 1.0).(float64); ok {
blink_phase = time.Duration(float64(time.Second) * p)
}
// Divided by two since we're only doing a simple toggle blink
timer := time.NewTimer(blink_phase / 2)
select {
case ev := <-evchan:
mp := util.Prof.Enter("evchan")
limit := 3
loop:
switch ev.Type {
case termbox.EventError:
log4go.Debug("error occured")
return
case termbox.EventKey:
var kp backend.KeyPress
if ev.Ch != 0 {
kp.Key = backend.Key(ev.Ch)
} else if v2, ok := lut[ev.Key]; ok {
kp = v2
} else {
break
}
if ev.Key == termbox.KeyCtrlQ {
return
}
ed.HandleInput(kp)
blink = false
//.........这里部分代码省略.........