Skip to content

Commit

Permalink
Use mode.Make instead of mode.Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
xyproto committed Jul 24, 2022
1 parent 6168305 commit 7ceb4c3
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion v2/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,7 @@ func (e *Editor) DrawInstructions(c *vt100.Canvas, repositionCursor bool) error

func (e *Editor) usingGDBMightWork() bool {
switch e.mode {
case mode.AIDL, mode.Amber, mode.Basic, mode.Bat, mode.Bazel, mode.Blank, mode.CMake, mode.CS, mode.Clojure, mode.Config, mode.Doc, mode.Email, mode.Erlang, mode.Git, mode.Gradle, mode.HIDL, mode.HTML, mode.JSON, mode.Java, mode.JavaScript, mode.Kotlin, mode.Lisp, mode.Log, mode.Lua, mode.M4, mode.Makefile, mode.ManPage, mode.Markdown, mode.Nroff, mode.Oak, mode.Perl, mode.PolicyLanguage, mode.Python, mode.SQL, mode.Scala, mode.Shell, mode.Teal, mode.Text, mode.TypeScript, mode.Vim, mode.XML:
case mode.AIDL, mode.Amber, mode.Basic, mode.Bat, mode.Bazel, mode.Blank, mode.CMake, mode.CS, mode.Clojure, mode.Config, mode.Doc, mode.Email, mode.Erlang, mode.Git, mode.Gradle, mode.HIDL, mode.HTML, mode.JSON, mode.Java, mode.JavaScript, mode.Kotlin, mode.Lisp, mode.Log, mode.Lua, mode.M4, mode.Make, mode.ManPage, mode.Markdown, mode.Nroff, mode.Oak, mode.Perl, mode.PolicyLanguage, mode.Python, mode.SQL, mode.Scala, mode.Shell, mode.Teal, mode.Text, mode.TypeScript, mode.Vim, mode.XML:
// Nope
return false
case mode.Zig:
Expand Down
8 changes: 4 additions & 4 deletions v2/highlight.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (e *Editor) WriteLines(c *vt100.Canvas, fromline, toline LineIndex, cx, cy

escapeFunction := Escape
unEscapeFunction := UnEscape
if e.mode == mode.Makefile || e.mode == mode.Shell {
if e.mode == mode.Make || e.mode == mode.Shell {
escapeFunction = ShEscape
unEscapeFunction = ShUnEscape
}
Expand Down Expand Up @@ -353,17 +353,17 @@ func (e *Editor) WriteLines(c *vt100.Canvas, fromline, toline LineIndex, cx, cy
coloredString = unEscapeFunction(e.MultiLineString.Get(line))
case !q.multiLineComment && (strings.HasPrefix(trimmedLine, "#if") || strings.HasPrefix(trimmedLine, "#else") || strings.HasPrefix(trimmedLine, "#elseif") || strings.HasPrefix(trimmedLine, "#endif") || strings.HasPrefix(trimmedLine, "#define") || strings.HasPrefix(trimmedLine, "#pragma")):
coloredString = unEscapeFunction(e.MultiLineString.Get(line))
case e.mode != mode.Shell && e.mode != mode.Makefile && !strings.HasPrefix(trimmedLine, singleLineCommentMarker) && strings.HasSuffix(trimmedLine, "*/") && !strings.Contains(trimmedLine, "/*"):
case e.mode != mode.Shell && e.mode != mode.Make && !strings.HasPrefix(trimmedLine, singleLineCommentMarker) && strings.HasSuffix(trimmedLine, "*/") && !strings.Contains(trimmedLine, "/*"):
coloredString = unEscapeFunction(e.MultiLineComment.Get(line))
case (e.mode == mode.StandardML || e.mode == mode.OCaml) && !strings.HasPrefix(trimmedLine, singleLineCommentMarker) && strings.HasSuffix(trimmedLine, "*)") && !strings.Contains(trimmedLine, "(*"):
coloredString = unEscapeFunction(e.MultiLineComment.Get(line))
case e.mode != mode.Shell && e.mode != mode.Makefile && !strings.HasPrefix(trimmedLine, singleLineCommentMarker) && strings.LastIndex(trimmedLine, "/*") > strings.LastIndex(trimmedLine, "*/"):
case e.mode != mode.Shell && e.mode != mode.Make && !strings.HasPrefix(trimmedLine, singleLineCommentMarker) && strings.LastIndex(trimmedLine, "/*") > strings.LastIndex(trimmedLine, "*/"):
coloredString = unEscapeFunction(tout.DarkTags(string(textWithTags)))
case (e.mode == mode.StandardML || e.mode == mode.OCaml) && !strings.HasPrefix(trimmedLine, singleLineCommentMarker) && strings.LastIndex(trimmedLine, "(*") > strings.LastIndex(trimmedLine, "*)"):
coloredString = unEscapeFunction(tout.DarkTags(string(textWithTags)))
case q.containsMultiLineComments:
coloredString = unEscapeFunction(tout.DarkTags(string(textWithTags)))
case e.mode != mode.Shell && e.mode != mode.Makefile && !strings.HasPrefix(trimmedLine, singleLineCommentMarker) && (q.multiLineComment || q.stoppedMultiLineComment) && !strings.Contains(line, "\"/*") && !strings.Contains(line, "*/\"") && !strings.Contains(line, "\"(*") && !strings.Contains(line, "*)\"") && !strings.HasPrefix(trimmedLine, "#") && !strings.HasPrefix(trimmedLine, "//"):
case e.mode != mode.Shell && e.mode != mode.Make && !strings.HasPrefix(trimmedLine, singleLineCommentMarker) && (q.multiLineComment || q.stoppedMultiLineComment) && !strings.Contains(line, "\"/*") && !strings.Contains(line, "*/\"") && !strings.Contains(line, "\"(*") && !strings.Contains(line, "*)\"") && !strings.HasPrefix(trimmedLine, "#") && !strings.HasPrefix(trimmedLine, "//"):
// In the middle of a multi-line comment
coloredString = unEscapeFunction(e.MultiLineComment.Get(line))
case q.singleLineComment || q.stoppedMultiLineComment:
Expand Down
8 changes: 4 additions & 4 deletions v2/quotestate.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (q *QuoteState) ProcessRune(r, prevRune, prevPrevRune rune) {
}
}
case '*': // support multi-line comments
if q.mode != mode.Shell && q.mode != mode.Makefile && q.firstRuneInSingleLineCommentMarker != '#' && prevRune == '/' && (prevPrevRune == '\n' || prevPrevRune == ' ' || prevPrevRune == '\t') && q.None() {
if q.mode != mode.Shell && q.mode != mode.Make && q.firstRuneInSingleLineCommentMarker != '#' && prevRune == '/' && (prevPrevRune == '\n' || prevPrevRune == ' ' || prevPrevRune == '\t') && q.None() {
// C-style
q.multiLineComment = true
q.startedMultiLineComment = true
Expand All @@ -130,7 +130,7 @@ func (q *QuoteState) ProcessRune(r, prevRune, prevPrevRune rune) {
q.startedMultiLineComment = true
}
case '-': // support for HTML-style and XML-style multi-line comments
if q.mode != mode.Shell && q.mode != mode.Makefile && prevRune == '!' && prevPrevRune == '<' && q.None() {
if q.mode != mode.Shell && q.mode != mode.Make && prevRune == '!' && prevPrevRune == '<' && q.None() {
q.multiLineComment = true
q.startedMultiLineComment = true
}
Expand All @@ -140,7 +140,7 @@ func (q *QuoteState) ProcessRune(r, prevRune, prevPrevRune rune) {
switch {
case len(q.singleLineCommentMarkerRunes) == 1:
fallthrough
case q.mode != mode.Shell && q.mode != mode.Makefile && len(q.singleLineCommentMarkerRunes) > 1 && prevRune == q.firstRuneInSingleLineCommentMarker:
case q.mode != mode.Shell && q.mode != mode.Make && len(q.singleLineCommentMarkerRunes) > 1 && prevRune == q.firstRuneInSingleLineCommentMarker:
q.singleLineComment = true
q.startedMultiLineString = false
q.stoppedMultiLineComment = false
Expand All @@ -158,7 +158,7 @@ func (q *QuoteState) ProcessRune(r, prevRune, prevPrevRune rune) {
// r == '/'
fallthrough
case '/': // support C-style multi-line comments
if q.mode != mode.Shell && q.mode != mode.Makefile && q.firstRuneInSingleLineCommentMarker != '#' && prevRune == '*' {
if q.mode != mode.Shell && q.mode != mode.Make && q.firstRuneInSingleLineCommentMarker != '#' && prevRune == '*' {
q.stoppedMultiLineComment = true
q.multiLineComment = false
if q.startedMultiLineComment {
Expand Down
4 changes: 2 additions & 2 deletions v2/syntax.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func adjustSyntaxHighlightingKeywords(m mode.Mode) {
// Only highlight some words, to make them stand out
clearKeywords()
addKeywords = []string{"db", "dd", "dw", "int", "resb", "resd", "resw", "section", "syscall"}
case mode.Makefile, mode.Shell:
case mode.Make, mode.Shell:
addKeywords = []string{"--force", "-f", "checkout", "clean", "cmake", "configure", "dd", "do", "doas", "done", "endif", "exec", "fdisk", "for", "gdisk", "ifeq", "ifneq", "in", "make", "mv", "ninja", "rm", "rmdir", "setopt", "su", "sudo", "while"}
delKeywords = []string{"#else", "#endif", "as", "build", "default", "double", "exec", "finally", "float", "fn", "generic", "get", "long", "new", "no", "package", "pass", "property", "require", "ret", "set", "super", "super", "template", "type", "var", "with"}
if m == mode.Shell { // Only for shell scripts, not for Makefiles
Expand All @@ -177,7 +177,7 @@ func adjustSyntaxHighlightingKeywords(m mode.Mode) {
// comment for the current language mode the editor is in.
func (e *Editor) SingleLineCommentMarker() string {
switch e.mode {
case mode.Bazel, mode.CMake, mode.Config, mode.Crystal, mode.Makefile, mode.Nim, mode.PolicyLanguage, mode.Python, mode.Shell:
case mode.Bazel, mode.CMake, mode.Config, mode.Crystal, mode.Make, mode.Nim, mode.PolicyLanguage, mode.Python, mode.Shell:
return "#"
case mode.Assembly:
return ";"
Expand Down

0 comments on commit 7ceb4c3

Please sign in to comment.