Пример #1
0
// TODO: wait for client response, return true/false
func (t *tbfe) OkCancelDialog(msg, ok string) bool {
	log.Info(msg, ok)

	t.BroadcastData(map[string]interface{}{"type": "okCancelDialog", "msg": msg, "ok": ok})

	return false
}
Пример #2
0
func (e *Editor) Init() {
	log.Info("Initializing")
	e.SetClipboardFuncs(setClipboard, getClipboard)
	e.loadKeyBindings()
	e.loadSettings()
	OnInit.call()
}
Пример #3
0
func (e *Editor) loadSetting(pkg *packages.Packet) {
	if err := pkg.Load(); err != nil {
		log.Error(err)
	} else {
		log.Info("Loaded %s", pkg.Name())
		e.Watch(pkg.Name(), pkg)
	}
}
Пример #4
0
func (e *Editor) loadKeyBinding(pkg *packages.Packet) {
	if err := pkg.Load(); err != nil {
		log.Error(err)
	} else {
		log.Info("Loaded %s", pkg.Name())
		e.Watch(pkg.Name(), pkg)
	}
	e.keyBindings.Merge(pkg.MarshalTo().(*keys.KeyBindings))
}
Пример #5
0
func (e *Editor) load(pkg *packages.Packet) {
	if err := pkg.Load(); err != nil {
		log.Errorf("Failed to load packet %s: %s", pkg.Name(), err)
	} else {
		log.Info("Loaded %s", pkg.Name())
		if err := e.Watch(pkg.Name(), pkg); err != nil {
			log.Warn("Couldn't watch %s: %s", pkg.Name(), err)
		}
	}
}
Пример #6
0
func sublime_Console(tu *py.Tuple, kwargs *py.Dict) (py.Object, error) {
	if tu.Size() != 1 {
		return nil, fmt.Errorf("Unexpected argument count: %d", tu.Size())
	}
	if i, err := tu.GetItem(0); err != nil {
		return nil, err
	} else {
		log.Info("Python sez: %s", i)
	}
	return toPython(nil)
}
Пример #7
0
func TestGlobalLog(t *testing.T) {
	var wg sync.WaitGroup
	log.Global.Close()
	log.Global.AddFilter("globaltest", log.FINEST, testlogger(func(str string) {
		if str != "Testing: hello world" {
			t.Errorf("got: %s", str)
		}
		wg.Done()
	}))
	wg.Add(1)
	log.Info("Testing: %s %s", "hello", "world")
	wg.Wait()
}
Пример #8
0
func (ch *commandHandler) RunApplicationCommand(name string, args Args) error {
	p := Prof.Enter("ac")
	defer p.Exit()
	if ch.log {
		log.Info("Running application command: %s %v", name, args)
	} else {
		log.Fine("Running application command: %s %v", name, args)
	}
	if c, ok := ch.ApplicationCommands[name].(ApplicationCommand); c != nil && ok {
		if err := ch.init(c, args); err != nil && ch.verbose {
			log.Debug("Command initialization failed: %s", err)
			return err
		} else if err := c.Run(); err != nil && ch.verbose {
			log.Debug("Command execution failed: %s", err)
			return err
		}
	}
	return nil
}
Пример #9
0
// On plugin reload we will scan for plugin files
// and packets in plugin path
func (p *Plugin) Reload() {
	var files []os.FileInfo
	log.Info("Reloading plugin %s", p.Name())
	f, err := os.Open(p.path)
	if err != nil {
		log.Errorf("Couldn't open dir: %s", err)
		return
	}
	defer f.Close()
	fi, err := f.Readdir(-1)
	if err != nil {
		log.Errorf("Couldn't read dir: %s", err)
		return
	}
	for _, f := range fi {
		if p.suffix != "" && strings.HasSuffix(f.Name(), p.suffix) {
			files = append(files, f)
		}
	}
	p.files = files
}
Пример #10
0
// On plugin reload we will scan for plugin files
// and packets in plugin path
func (p *Plugin) Reload() {
	var (
		files []os.FileInfo
		pckts Packets
	)
	log.Info("Reloading plugin %s", p.Name())
	f, err := os.Open(p.path)
	if err != nil {
		log.Error("Couldn't open dir: %s", err)
		return
	}
	defer f.Close()
	fi, err := f.Readdir(-1)
	if err != nil {
		log.Error("Couldn't read dir: %s", err)
		return
	}
	for _, f := range fi {
		if p.suffix != "" && strings.HasSuffix(f.Name(), p.suffix) {
			files = append(files, f)
			continue
		}
		s := filepath.Ext(f.Name())
		for _, t := range types {
			if !strings.Contains(s, t) {
				continue
			}
			var pckt *Packet
			if t == "keymap" {
				pckt = NewPacket(pt.Join(p.path, f.Name()), new(keys.KeyBindings))
			} else {
				// We don't have any settings hierarchy for plugins at this moment
				pckt = NewPacket(pt.Join(p.path, f.Name()), p.Settings())
			}
			pckts = append(pckts, pckt)
		}
	}
	p.files = files
	p.packets = pckts
}
Пример #11
0
// TODO(q): Actually show a dialog
func (t *tbfe) MessageDialog(msg string) {
	log.Info(msg)
}
Пример #12
0
func (h *DummyFrontend) OkCancelDialog(msg string, button string) bool {
	log.Info(msg)
	h.m.Lock()
	defer h.m.Unlock()
	return h.defaultAction
}
Пример #13
0
func (h *DummyFrontend) MessageDialog(msg string) { log.Info(msg) }
Пример #14
0
func (h *DummyFrontend) StatusMessage(msg string) { log.Info(msg) }
Пример #15
0
func (t *tbfe) MessageDialog(msg string) {
	log.Info(msg)

	t.BroadcastData(map[string]interface{}{"type": "messageDialog", "msg": msg})
}
Пример #16
0
func (t *tbfe) WebsocketServer(ws *websocket.Conn) {
	clients = append(clients, ws)

	// Send status message
	if t.status_message != "" {
		websocket.JSON.Send(ws, map[string]string{"type": "statusMessage", "msg": t.status_message})
	}

	// Send cursor position
	websocket.JSON.Send(ws, t.GetSelectionMessage(backend.GetEditor().ActiveWindow().ActiveView()))

	// Send editor content
	var buf bytes.Buffer
	t.render(bufio.NewWriter(&buf))
	websocket.Message.Send(ws, buf.Bytes())
	buf.Reset()

	var data map[string]interface{}
	var kp keys.KeyPress
	for {
		err := websocket.JSON.Receive(ws, &data)
		if err != nil {
			log.Error(err)
			return
		}
		//log.LogDebug("Received: %s", data)

		msgType := data["type"].(string)

		if msgType == "key" {
			kp.Alt = data["altKey"].(bool)
			kp.Ctrl = data["ctrlKey"].(bool)
			kp.Super = data["metaKey"].(bool)
			kp.Shift = data["shiftKey"].(bool)

			if keyName, ok := data["key"].(string); ok {
				if utf8.RuneCountInString(keyName) == 1 { // One char
					r, _ := utf8.DecodeRuneInString(keyName)
					kp.Key = keys.Key(int64(r))
				} else {
					// TODO: automatic lookup instead of this manual lookup
					// See https://github.com/limetext/lime/pull/421/files#r19269236
					keymap := map[string]keys.Key{
						"ArrowLeft":   keys.Left,
						"ArrowUp":     keys.Up,
						"ArrowRight":  keys.Right,
						"ArrowDown":   keys.Down,
						"Left":        keys.Left,
						"Up":          keys.Up,
						"Right":       keys.Right,
						"Down":        keys.Down,
						"Enter":       keys.Enter,
						"Escape":      keys.Escape,
						"Backspace":   keys.Backspace,
						"Delete":      keys.Delete,
						"Del":         keys.Delete, // Deprecated: some old browsers still use "Del" instead of "Delete"
						"KeypadEnter": keys.KeypadEnter,
						"F1":          keys.F1,
						"F2":          keys.F2,
						"F3":          keys.F3,
						"F4":          keys.F4,
						"F5":          keys.F5,
						"F6":          keys.F6,
						"F7":          keys.F7,
						"F8":          keys.F8,
						"F9":          keys.F9,
						"F10":         keys.F10,
						"F11":         keys.F11,
						"F12":         keys.F12,
						"Insert":      keys.Insert,
						"PageUp":      keys.PageUp,
						"PageDown":    keys.PageDown,
						"Home":        keys.Home,
						"End":         keys.End,
						"Break":       keys.Break,
					}

					if key, ok := keymap[keyName]; ok {
						kp.Key = key
					} else {
						log.Debug("Unknown key: %s", keyName)
						continue
					}
				}
			} else {
				v := int64(data["keyCode"].(float64))
				if !kp.Shift {
					v = int64(unicode.ToLower(rune(v)))
				}
				kp.Key = keys.Key(v)
			}

			backend.GetEditor().HandleInput(kp)
		} else if msgType == "command" {
			command := data["name"].(string)
			//args := data["args"].([]string) //TODO: add arguments support

			ed := backend.GetEditor()
			go ed.RunCommand(command, make(backend.Args))
		} else {
			log.Info("Unhandled message type: %s", msgType)
		}
	}
}
Пример #17
0
// TODO(q): Actually show a dialog
func (t *tbfe) OkCancelDialog(msg, ok string) bool {
	log.Info(msg, ok)
	return false
}