Skip to content

Commit

Permalink
Working with ST3
Browse files Browse the repository at this point in the history
Fixes for python 3 syntax and string to bytes conversion.
  • Loading branch information
shirosaki committed Apr 6, 2013
1 parent adb4348 commit 5ab00b7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
9 changes: 6 additions & 3 deletions sublimeibus/async.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# -*- coding: utf-8 -*-
import os
import thread
import subprocess
import logging
try:
import _thread as thread
except ImportError:
import thread


if os.name == "nt" and not hasattr(subprocess, 'STARTF_USESHOWWINDOW'):
Expand Down Expand Up @@ -127,15 +130,15 @@ def stop(self):

def send(self, data):
if self.async is not None:
return self.async.proc.stdin.write(data)
return self.async.proc.stdin.write(data.encode('utf-8'))
else:
raise

def push(self, data):
self.send(data)

def handle_read(self, data):
buf = data
buf = data.decode('utf-8')
terminator = self.get_terminator()

while True:
Expand Down
4 changes: 2 additions & 2 deletions sublimeibus/sublime-ibus-agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ def focus_in(id_no):

def focus_out(id_no):
imcontexts[id_no].focus_out()
print '{}' # Dummy response
print('{}') # Dummy response

def reset(id_no):
imcontexts[id_no].reset()
Expand Down Expand Up @@ -562,7 +562,7 @@ def __start_cb(self):
def __stdin_cb(self, fd, condition):
try:
expr = sys.stdin.readline()
exec expr
exec(expr)
except:
import traceback
print_command('error', 'error expr: ' + expr)
Expand Down
13 changes: 9 additions & 4 deletions sublimeibusplugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
import os
import json
from os.path import join
from sublimeibus import host
import sys

BASE_PATH = os.path.abspath(os.path.dirname(__file__))
sys.path += [BASE_PATH] + [join(BASE_PATH, 'sublimeibus')]

from sublimeibus.host import agent


class Logger(object):
Expand Down Expand Up @@ -190,9 +195,9 @@ def on_data(data):
logger.debug(repr(data))


host.agent.register_callback(on_data)
host.agent.restart(join(os.getcwd(), 'sublimeibus'))
agent.register_callback(on_data)
agent.restart(join(BASE_PATH, 'sublimeibus'))

status = IBusStatus()
command = IBusCommand(host.agent)
command = IBusCommand(agent)
command.setup()

0 comments on commit 5ab00b7

Please sign in to comment.