mirror of
https://github.com/tbabej/taskwiki.git
synced 2025-08-19 06:43:06 +02:00
main: Make callback splits work with Python3
This commit is contained in:
parent
df2b5f87e6
commit
183f40b99d
1 changed files with 12 additions and 3 deletions
|
@ -1,4 +1,5 @@
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
import base64
|
||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
import pickle
|
import pickle
|
||||||
|
@ -387,14 +388,22 @@ class CallbackSplitMixin(object):
|
||||||
|
|
||||||
# We can't save the current instance in vim variable
|
# We can't save the current instance in vim variable
|
||||||
# so save the pickled version
|
# so save the pickled version
|
||||||
vim.current.buffer.vars['taskwiki_callback'] = pickle.dumps(self)
|
if six.PY2:
|
||||||
|
vim.current.buffer.vars['taskwiki_callback'] = pickle.dumps(self)
|
||||||
|
else:
|
||||||
|
vim.current.buffer.vars['taskwiki_callback'] = base64.encodebytes(
|
||||||
|
bytes(pickle.dumps(self))
|
||||||
|
).decode()
|
||||||
|
|
||||||
# Remap <CR> to calling the callback and wiping the buffer
|
# Remap <CR> to calling the callback and wiping the buffer
|
||||||
vim.command(
|
vim.command(
|
||||||
"nnoremap <silent> <buffer> <enter> :"
|
"nnoremap <silent> <buffer> <enter> :"
|
||||||
+ vim.vars['taskwiki_py'].decode() +
|
+ vim.vars['taskwiki_py'].decode() +
|
||||||
"callback = pickle.loads("
|
"callback = pickle.loads(" +
|
||||||
"vim.current.buffer.vars['taskwiki_callback']); "
|
( "base64.decodebytes("
|
||||||
|
"vim.current.buffer.vars['taskwiki_callback'])); "
|
||||||
|
if six.PY3 else
|
||||||
|
"vim.current.buffer.vars['taskwiki_callback']); " ) +
|
||||||
"callback.callback(); "
|
"callback.callback(); "
|
||||||
"vim.command('bwipe') <CR>"
|
"vim.command('bwipe') <CR>"
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue