google / ci_edit

A terminal text editor with mouse support and ctrl+Q to quit.
Apache License 2.0
222 stars 53 forks source link

Color code uppercase words #114

Open aaxu opened 6 years ago

aaxu commented 6 years ago

Seems like a good feature, both for coding and note taking., since I use caps for some headers and terms. Maybe a nice blue? Although I think I said before, but this could make the message line at the bottom of the screen ("Save changes? (yes, no, or cancel):") less noticeable when it appears. I don't think we've used green, brown, magenta, or yellow yet, so maybe one of these basic colors? We could also play around with maybe the background rather than the foreground color, though I don't think that would be very aesthetically pleasing. Maybe we could have a highlighting feature though or custom text colors that allow for overriding these defaults.

dschuyler commented 6 years ago

For note taking, maybe the 'text' grammar could be augmented? Here's what that looks like now.

    'text': {
      'indent': '  ',
      'special': [__sha_1,],
      'contains': ['quoted_string1', 'quoted_string2'],
    },

So quoted strings have color and so to sha1 sequences.

Maybe add a keywords line

      'keywords': ['[A-Z]{2,}',],

Or add to 'special'

      'special': [__sha_1,  '\b[A-Z]{2,}\b',],

(Don't put it in both keywords and special because one will take precedence anyway).

Keywords are a different color from a 'special'. Also, keywords automatically have \b added to the beginning and end. So if you'd like to get the caps in FOObar a 'special' (without \b) will be needed (because 'keywords' will only match whole words due to the \b at the beginning and end).

aaxu commented 6 years ago

I personally would prefer the entire word being highlighted, as it might irk me if only half of it is highlighted as in FOObar. Also, what is the 'special' field and how is it different from the 'keywords' aside from the \b appending? Is the comment underneath 'grammar': up to date with this 'special' field?

dschuyler commented 6 years ago

Is the comment underneath 'grammar': up to date with this 'special' field?

Nope! Fixed.

I also just added another highlighting set for 'error'. It's very similar to 'special' except that it draws the text in reverse, bold, red.

Mainly the differences between them are choosing whether you'd like them drawn in blue, or brown, or reverse-bold-red. (Other than keywords being whole-word matches).*

*of course, this may vary depending on what the color palette is set to.

aaxu commented 6 years ago

Oh okay! Cool, I'll probably play around with this a bit more and note down some possible improvements as I try to finish some projects. Is there a way you can set the document (grammar) type, or is that automatically detected via the file name's extension?

aaxu commented 6 years ago

Do we currently have something that displays the palette? If I remember correctly, it was set to be F4 before, but it wasn't working.

dschuyler commented 6 years ago

There is, but it's buggy so I often disable it. Search for

KEY_F4: self.changeToPaletteWindow,

in ci_edit/app/cu_editor.py and uncomment it.

aaxu commented 6 years ago

This should be resolved via #138. Still don't know how to tell which file mode is active (.txt, .py, .c) and how to change it dynamically in the program (unless this isn't implemented yet)