From d05a74cca10f8ea90c622765fb3c9c1830aad0ab Mon Sep 17 00:00:00 2001 From: Felix Angell Date: Tue, 17 Apr 2018 03:06:26 +0100 Subject: [PATCH] c language: directives, string literals, single line comments --- cfg/linuxconfig.go | 17 ++++++++++++++++- cfg/macconfig.go | 44 +++++++++++++++++++++++++++++--------------- cfg/windowsconfig.go | 20 ++++++++++++++++++-- gui/buffer.go | 2 -- 4 files changed, 63 insertions(+), 20 deletions(-) diff --git a/cfg/linuxconfig.go b/cfg/linuxconfig.go index 25f683a..851b71e 100644 --- a/cfg/linuxconfig.go +++ b/cfg/linuxconfig.go @@ -7,6 +7,8 @@ tabs_are_spaces = true match_braces = false maintain_indentation = true highlight_line = true +font_face = "Courier New" +font_size = 20 show_line_numbers = true [render] @@ -43,7 +45,7 @@ match = [ [syntax.go.comment] colouring = 0x4b79fc -pattern = "[\\/]+.*" +pattern = '//.*' [syntax.go.symbol] colouring = 0xf0a400 @@ -53,6 +55,7 @@ match = [ ] [syntax.c] + [syntax.c.type] colouring = 0xff0000 match = [ @@ -68,6 +71,18 @@ match = [ "goto", "static", "extern", "const", "typedef", ] +[syntax.c.string_literal] +colouring = 0xff0000 +pattern = "\"([^\\\"]|\\.)*\"" + +[syntax.c.directive] +colouring = 0xf0a400 +pattern = "^\\s*#\\s*include\\s+(?:<[^>]*>|\"[^\"]*\")\\s*" + +[syntax.c.comment] +colouring = 0x4b79fc +pattern = '//.*' + [theme] background = 0x002649 foreground = 0xf2f4f6 diff --git a/cfg/macconfig.go b/cfg/macconfig.go index 088bcff..8de0964 100644 --- a/cfg/macconfig.go +++ b/cfg/macconfig.go @@ -7,7 +7,7 @@ tabs_are_spaces = true match_braces = false maintain_indentation = true highlight_line = true -font_face = "Courier New Bold" +font_face = "Courier New" font_size = 20 show_line_numbers = true @@ -17,18 +17,6 @@ accelerated = true throttle_cpu_usage = true always_render = true -[theme] -background = 0x002649 -foreground = 0xf2f4f6 -cursor = 0xf2f4f6 -cursor_invert = 0x000000 - -[cursor] -flash_rate = 400 -reset_delay = 400 -draw = true -flash = true - [file_associations] [file_associations.c] extensions = [".c", ".h", ".cc"] @@ -57,7 +45,7 @@ match = [ [syntax.go.comment] colouring = 0x4b79fc -pattern = "[\\/]+.*" +pattern = '//.*' [syntax.go.symbol] colouring = 0xf0a400 @@ -67,6 +55,7 @@ match = [ ] [syntax.c] + [syntax.c.type] colouring = 0xff0000 match = [ @@ -82,6 +71,30 @@ match = [ "goto", "static", "extern", "const", "typedef", ] +[syntax.c.string_literal] +colouring = 0xff0000 +pattern = "\"([^\\\"]|\\.)*\"" + +[syntax.c.directive] +colouring = 0xf0a400 +pattern = "^\\s*#\\s*include\\s+(?:<[^>]*>|\"[^\"]*\")\\s*" + +[syntax.c.comment] +colouring = 0x4b79fc +pattern = '//.*' + +[theme] +background = 0x002649 +foreground = 0xf2f4f6 +cursor = 0xf2f4f6 +cursor_invert = 0x000000 + +[cursor] +flash_rate = 400 +reset_delay = 400 +draw = true +flash = true + [commands] [commands.save] shortcut = "super+s" @@ -90,4 +103,5 @@ shortcut = "super+s" shortcut = "super+w" [commands.delete_line] -shortcut = "super+d"` +shortcut = "super+d" +` diff --git a/cfg/windowsconfig.go b/cfg/windowsconfig.go index b2c8591..580801a 100644 --- a/cfg/windowsconfig.go +++ b/cfg/windowsconfig.go @@ -7,6 +7,8 @@ tabs_are_spaces = true match_braces = false maintain_indentation = true highlight_line = true +font_face = "Courier New" +font_size = 20 show_line_numbers = true [render] @@ -43,7 +45,7 @@ match = [ [syntax.go.comment] colouring = 0x4b79fc -pattern = "[\\/]+.*" +pattern = '//.*' [syntax.go.symbol] colouring = 0xf0a400 @@ -53,6 +55,7 @@ match = [ ] [syntax.c] + [syntax.c.type] colouring = 0xff0000 match = [ @@ -68,6 +71,18 @@ match = [ "goto", "static", "extern", "const", "typedef", ] +[syntax.c.string_literal] +colouring = 0xff0000 +pattern = "\"([^\\\"]|\\.)*\"" + +[syntax.c.directive] +colouring = 0xf0a400 +pattern = "^\\s*#\\s*include\\s+(?:<[^>]*>|\"[^\"]*\")\\s*" + +[syntax.c.comment] +colouring = 0x4b79fc +pattern = '//.*' + [theme] background = 0x002649 foreground = 0xf2f4f6 @@ -88,4 +103,5 @@ shortcut = "ctrl+s" shortcut = "ctrl+w" [commands.delete_line] -shortcut = "ctrl+d"` +shortcut = "ctrl+d" +` diff --git a/gui/buffer.go b/gui/buffer.go index 847e132..d76db22 100644 --- a/gui/buffer.go +++ b/gui/buffer.go @@ -853,10 +853,8 @@ func (b *Buffer) renderAt(ctx *strife.Renderer, rx int, ry int) { matched := regex.FindStringIndex(a) if matched != nil { - // for some reason this affects the whole line if _, ok := matches[charIndex]; !ok { matchedStrLen := (matched[1] - matched[0]) - matches[charIndex+matched[0]] = syntaxRuneInfo{colours[syntaxIndex], -1, matchedStrLen} charIndex = charIndex + matchedStrLen }