bim: sync with upstream

This commit is contained in:
K. Lange 2021-11-17 11:22:27 +09:00
parent b1a236c88f
commit d8b1628732
5 changed files with 41 additions and 1 deletions

View File

@ -967,10 +967,15 @@ void recalculate_syntax(line_t * line, int line_no) {
s->state.i = 0;
while (1) {
struct termios old, new;
tcgetattr(global_config.tty_in, &old);
new = old; new.c_lflag |= ISIG;
tcsetattr(global_config.tty_in, TCSAFLUSH, &new);
ptrdiff_t before = krk_currentThread.stackTop - krk_currentThread.stack;
krk_push(OBJECT_VAL(env->syntax->krkFunc));
krk_push(OBJECT_VAL(s));
KrkValue result = krk_callStack(1);
tcsetattr(global_config.tty_in, TCSAFLUSH, &old);
krk_currentThread.stackTop = krk_currentThread.stack + before;
if (IS_NONE(result) && (krk_currentThread.flags & KRK_THREAD_HAS_EXCEPTION)) {
render_error("Exception occurred in plugin: %s", AS_INSTANCE(krk_currentThread.currentException)->_class->name->chars);
@ -3437,6 +3442,11 @@ void SIGCONT_handler(int sig) {
signal(SIGTSTP, SIGTSTP_handler);
}
void SIGINT_handler(int sig) {
krk_currentThread.flags |= KRK_THREAD_SIGNALLED;
signal(SIGINT, SIGINT_handler);
}
void try_to_center() {
int half_a_screen = (global_config.term_height - 3) / 2;
if (half_a_screen < env->line_no) {
@ -11127,6 +11137,7 @@ void init_terminal(void) {
signal(SIGWINCH, SIGWINCH_handler);
signal(SIGCONT, SIGCONT_handler);
signal(SIGTSTP, SIGTSTP_handler);
signal(SIGINT, SIGINT_handler);
}
struct action_def * find_action(void (*action)()) {

View File

@ -22,7 +22,7 @@ class BashHighlighter(Highlighter):
def paintTick(self, outState):
let last = None
while self[0] != None:
if last != '\\' and self[0] == "'":
if self[0] == "'":
self.paint(1, self.FLAG_STRING)
return self.popState(outState)
else if last == '\\':

View File

@ -29,9 +29,11 @@ class JavaHighlighter(Highlighter):
]
def atKeywordQualifier(c):
if isinstance(c,int) and c > 0: c = chr(c)
else if isinstance(c,int) and c <= 0: return False
return self.isalnum(c) or c in '_@'
def braceKeywordQualifier(c):
if isinstance(c,int) and c > 0: c = chr(c)
else if isinstance(c,int) and c <= 0: return False
return self.isalnum(c) or c in '{@_'
def keywordQualifier(c):
return self.cKeywordQualifier(c)

View File

@ -0,0 +1,25 @@
from syntax import Highlighter, bind
class LatexHighlighter(Highlighter):
name = "latex"
extensions = ('.tex',)
spaces = True
def calculate(self):
while self[0]:
if self[0] == '%':
self.paintComment()
return None
else if self[0] == '\\':
if self.isalpha(self[1]):
self.paint(2, self.FLAG_KEYWORD)
while self.isalpha(self[0]):
self.paint(1, self.FLAG_KEYWORD)
else:
self.skip()
else:
self.skip()
return None
bind(LatexHighlighter)

View File

@ -97,6 +97,8 @@ class HTMLHighlighter(XMLHighlighter):
if result == 0:
self.__init__(css)
continue
else if result == 1:
return 7
else if result == None:
return 6
if (self[0] == '<' and self[1] == '/' and self[2] == 's'):