XhmikosR / notepad2-mod

LOOKING FOR DEVELOPERS - Notepad2-mod, a Notepad2 fork, a fast and light-weight Notepad-like text editor with syntax highlighting
https://xhmikosr.github.io/notepad2-mod/
Other
1.45k stars 270 forks source link

Single-quoted strings not highlighted in Lua #44

Closed Phanx closed 11 years ago

Phanx commented 11 years ago

Lua treats 'single-quoted strings' and "double-quoted strings" identically, but Notepad2-mod is only highlighting double-quoted strings as strings. Single-quoted strings are not getting any syntax highlighting applied, and are shown with default text settings.

This issue isn't affecting other lexers like PHP or JavaScript.

XhmikosR commented 11 years ago

Just saying something this way not only does not help but instead it has the opposite effect.

I need a sample.

Phanx commented 11 years ago

Not sure what kind of example you're looking for other than just typing some strings in, but here:

exampleDQ = "double quoted string"
exampleSQ = 'single quoted string'
exampleLS = [[literal string]]
  1. Paste the above 3 lines into a new document.
  2. Select Scheme > Lua Script > OK
  3. Observe:
    • The "double quoted string" is highlighted as per Customize Schemes > Lua Script > String.
    • The [[literal string]] is highlighted as per Customize Schemes > Lua Script > Literal String.
    • The 'single quoted string' is not highlighted at all, and uses the settings from Customize Schemes > Default Text > Default Style.

Here are screenshots of the above example along with screenshots of my settings for Lua strings, Lua literal strings, and default text.

Select Scheme > Lua Script

1-select-lua

Customize Scheme > Default Text > Default Style

2-customize-default-default

Customize Scheme > Lua Script > String

3-customize-lua-string

Customize Scheme > Lua Script > Literal String

4-customize-lua-literalstring

If there's something else you need, please be specific about what it is, and I'm happy to provide it.

XhmikosR commented 11 years ago

Thanks for the detailed report.

With the default settings it seems to work fine; the single quoted string is highlighted properly, like the double quoted string. The behavior is the same as Scite, which uses the Scintilla library, the same library Notepad2 is using. So I don't see anything wrong here...

28-05-2013 08-59-28

I might try later with your settings to see if I can reproduce the problem then. Your best bet is to try to reproduce the issue with Scite; if it's a problem there we need to report it upstream.

Also perhaps you can check if this happens with other languages too.

Phanx commented 11 years ago

It doesn't happen with CSS, JavaScript, or Web Source Code.

However, after poking around in the default settings, I think I've found the actual problem -- single-quoted strings are being classified as "Character" instead of "String" for the Lua Script scheme. I'm not sure what "Character" is even supposed to represent for the Lua highlighting scheme, as any sequence of characters enclosed in single quotation marks is classified as a string by the Lua language, I've never seen the word "character" used in Lua documentation to refer to anything other than the numbers, letters, or other characters in a string, and none of the other highlighting schemes have a "Character" class to try to compare with.

Probably you should just merge the "Character" class into "String" if that's within your control.

XhmikosR commented 11 years ago

That's the easy part. If you think that's correct I can do it later.

I added Lua support because I needed it back then, but it's not a language I'm familiar with.

XhmikosR commented 11 years ago

Test build with:

From 3f0683da988fd0db50b4091a306552b79797eb7c Mon Sep 17 00:00:00 2001
From: XhmikosR <xhmikosr@users.sourceforge.net>
Date: Tue, 28 May 2013 09:10:38 +0300
Subject: [PATCH 2/2] Tweak Lua highlighting:

* Add Lua label
* Merge Character into String
---
 src/Styles.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/Styles.c b/src/Styles.c
index b196e6d..879221a 100644
--- a/src/Styles.c
+++ b/src/Styles.c
@@ -1297,12 +1297,12 @@ EDITLEXER lexLUA = { SCLEX_LUA, 63298, L"Lua Script", L"lua", L"", &KeyWords_LUA
                     { SCE_LUA_WORD2, 63321, L"Basic Functions", L"fore:#00007F", L"" },
                     { SCE_LUA_WORD3, 63322, L"String, Table & Math Functions", L"fore:#00007F", L"" },
                     { SCE_LUA_WORD4, 63323, L"Input, Output & System Facilities", L"fore:#00007F", L"" },
-                    { MULTI_STYLE(SCE_LUA_STRING,SCE_LUA_STRINGEOL,0,0), 63131, L"String", L"fore:#B000B0", L"" },
+                    { MULTI_STYLE(SCE_LUA_STRING,SCE_LUA_STRINGEOL,SCE_LUA_CHARACTER,0), 63131, L"String", L"fore:#B000B0", L"" },
                     { SCE_LUA_LITERALSTRING, 63302, L"Literal String", L"fore:#B000B0", L"" },
-                    { SCE_LUA_CHARACTER, 63301, L"Character", L"fore:#B000B0", L"" },
                     { SCE_LUA_PREPROCESSOR, 63133, L"Preprocessor", L"fore:#FF8000", L"" },
                     { SCE_LUA_OPERATOR, 63132, L"Operator", L"", L"" },
                     { SCE_LUA_IDENTIFIER, 63129, L"Identifier", L"", L"" },
+                    { SCE_LUA_LABEL, 63235, L"Label", L"fore:#808000", L"" },
                     { -1, 00000, L"", L"", L"" } } };

-- 
1.8.1.msysgit.1

https://dl.dropboxusercontent.com/u/3607425/Notepad2-mod/Notepad2-mod.zip

Let me know what you think and if it's OK I will push the patch.

QWp6t commented 11 years ago

@phanx

this is unrelated to this issue. i'm just wondering if you can export your color scheme and post it here because i dig it.

Phanx commented 11 years ago

@XhmikosR: The patch looks good.

@QWp6t: My color scheme is a modified version of some guy's modified Monokai scheme I found somewhere. I've only been using it for about a week. Lua looks good, but I just looked at a few other languages and most of them seem to need work, so you should probably just copy the colors from Lua if your language(s) of choice aren't set up properly. (I've never noticed before, but GitHub has no PM feature?!)

https://dl.dropboxusercontent.com/u/52910157/Monokai.ini

QWp6t commented 11 years ago

I apologize in advance to anyone who gets notified of this message, especially since it's now closed. Sorry fellas. I'll exit this discussion after this message.

I just wanted to say thanks for the link. I appreciate it.