From 78fb01186acf23ace4af786da836b1412bbcc204 Mon Sep 17 00:00:00 2001 From: GrenderG Date: Sat, 8 Apr 2017 02:46:17 +0200 Subject: [PATCH] Added Python support. --- tte.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/tte.c b/tte.c index 9669de0..f821b1b 100644 --- a/tte.c +++ b/tte.c @@ -51,7 +51,7 @@ // Version code #define TTE_VERSION "0.0.1" // Length of a tab stop -#define TTE_TAB_STOP 8 +#define TTE_TAB_STOP 4 // Times to press Ctrl-Q before exiting #define TTE_QUIT_TIMES 3 // Highlight flags @@ -146,15 +146,17 @@ enum editor_highlight { /*** Filetypes ***/ char* C_HL_extensions[] = {".c", ".h", ".cpp", NULL}; // Array must be terminated with NULL. +char* JAVA_HL_extensions[] = {".java", NULL}; +char* PYTHON_HL_extensions[] = {".py", NULL}; + char* C_HL_keywords[] = { - "switch", "if", "while", "for", "break", "continue", "return", "else", - "struct", "union", "typedef", "static", "enum", "class", "case", "#include", - "#define", - "int|", "long|", "double|", "float|", "char|", "unsigned|", "signed|", - "void|", NULL + "switch", "if", "while", "for", "break", "continue", "return", "else", + "struct", "union", "typedef", "static", "enum", "class", "case", "#include", + "#define", + "int|", "long|", "double|", "float|", "char|", "unsigned|", "signed|", + "void|", NULL }; -char* JAVA_HL_extensions[] = {".java", NULL}; char* JAVA_HL_keywords[] = { "switch", "if", "while", "for", "break", "continue", "return", "else", "in", "public", "private", "protected", "static", "final", "abstract", @@ -166,6 +168,13 @@ char* JAVA_HL_keywords[] = { "boolean|", NULL }; +char* PYTHON_HL_keywords[] = { + "and", "as", "assert", "break", "class", "continue", "def", "del", "elif", + "else", "except", "exec", "finally", "for", "from", "global", "if", "import", + "in", "is", "lambda", "not", "or", "pass", "print", "raise", "return", "try", + "while", "with", "yield", NULL +}; + struct editor_syntax HL_DB[] = { { "c", @@ -185,6 +194,15 @@ struct editor_syntax HL_DB[] = { "*/", HL_HIGHLIGHT_NUMBERS | HL_HIGHLIGHT_STRINGS }, + { + "python", + PYTHON_HL_extensions, + PYTHON_HL_keywords, + "#", + "'''", + "'''", + HL_HIGHLIGHT_NUMBERS | HL_HIGHLIGHT_STRINGS + }, }; // Size of the "Hightlight Database" (HL_DB).