Notepad++ User Defined Language for Arduino

This thread has been superseded by this Notepad++ User Defined Language for Arduino

Apart for simple programs I find the arduino IDE a bit lacking. I tend to use Notepad++ for larger projects but found the built in C++ language setting did not highlight some arduino keywords so I have started working on a User Defined Language to better suit the arduino.
Attached is my work in progress, I the hope someone else may find it helpful.
I have not exhaustive added all the core keywords yet so there may be some problems.
EDIT:
I have updated the language file so re-download to test.
EDIT2:
See later post for more compatible way to add Arduino to N++

userDefineLang.xml (4.3 KB)

What do we do with this xml file?

PaulS:
What do we do with this xml file?

Follow the instructions here Notepad++ download | SourceForge.net

Cool. Does it work with keywords defined in the keywords.txt files?

Also, you appear to have missed 'print' and 'println' :~

TCWORLD:
Cool. Does it work with keywords defined in the keywords.txt files?

Also, you appear to have missed 'print' and 'println' :~

The latest version I posted I only went through the main entries on the references page Arduino - Home but now you have told me about the more concise list I will update some more when I get time.
print & println work for me if proceeded by Serial. what context do you use it in that does not work?

what context do you use it in that does not work?

I haven't tried but maybe Serial1/2/3 and other 3rd party calls like lcd.print()


Rob

Have updated and uploaded (see first post) the language file to include the core keywords. A couple of known issues that I don't know how to work around are...
Arduino IDE colours entire #define, #if etc. lines in same colour (brown) but I can only get the keyword to colour and the rest of the line colours according to word/number scheme.
Folding/unfolding does not work properly if the bracket symbol '}' is directly on end of text.

void loop(){
  int x=y }      //Folds properly

  void loop(){
  int x=y}      //Does not fold properly

If I make {}, operators to cure problem of being directly on end of word then folding breaks altogether.

Graynomad:
I haven't tried but maybe Serial1/2/3 and other 3rd party calls like lcd.print()

Tricky one this, lcd is not a core keyword as it's derived from LiquidCrystal so could be called anything. I could add the .print etc keywords for standard libraries but obviously I cannot add all keywords for non standard libs.

Serial1/2/3 should be added in next few minutes. EDIT: Added

Surely, the best option would be to scan for, and parse, the existing keywords.txt files that the Arduino IDE uses for this purpose, and add the content to the XML file.

lcd is not a core keyword

Right, I thought there may be an option to do say *.print, {word}.print $word.print or whatever. OTOH this is just a variable or object like any other and you can't highlight every variable.


Rob

I have added all I can find fro the standard Libraries but despite adding entries like (.rightToLeft) for LCD they don't highlight. I suspect the simple user language in Notepad++ is beyond the complex lexicon definition needed or it's beyond me. :blush:
I have updated the attachment in the top post to the current definition I have created. Baring bug fixes I don't think I can do much more.

I suspect the simple user language in Notepad++ is beyond the complex lexicon definition needed

Quite possible.

I used to use Notepad++ for my Arduino programming so this should be a welcome addition when I return to coding for them.


Rob

I used to use Notepad++ for my Arduino programming so this should be a welcome addition when I return to coding for them.]I used to use Notepad++ for my Arduino programming so this should be a welcome addition when I return to coding for them.

I'm glad someone else may benefit from all this tinkering. I am surprised nobody else has done anything like this (that I could find) for NPP.
My latest thought is to download a portable version of NPP and add arduino keywords directly to the C++ language definition. As I don't otherwise program in C++ then I have no problem with potentially breaking the normal C++ setting but as it's the portable version it won't matter to me.

After several attempts to configure a Arduino bias user defined language for Notepad++ (NPP) I managed to get something close to what I wanted (all the core and standard library keywords) but some keywords would not highlight as expected and I put this down to limitations of the otherwise excellent NPP user language lexicon. I was going to give up at that but then had the idea of adding Arduino keywords to NPP's built in C++ lexicon. This does seem to work better but at the expense of confusing the C++ language for pure C++ programming. My final solution was to download a portable version of NPP and perform my Arduino C++ additions on this copy so I have a normal C++ version to fall back on if needed.
If your interested then download and extract a portable version of NPP via here Notepad++ Portable (development text editor) | PortableApps.com
Load it up, configure it to you liking and install any plugins you use.
Open Style Configurator (Settings->Style Configurator...)
Under 'Language' select 'C++' and then select 'INSTRUCTION WORD' under 'Style'. This should show two text boxes on the right called 'Default keywords' & 'User-defined keywords'.
Copy & paste the line below that begins 'abs acos' into the 'User-defined keywords' text box.
Under 'Style' select 'TYPE WORD' and copy & paste the below line beginning 'boolean byte' into the 'User-defined keywords' text box.
Under 'User ext.' type 'ino' (without the ' markers) into the box provided
Finally, click 'Save & Close' button and you should now have a portable Arduino bias C++ editor in NPP

INSTRUCTION WORDS

abs acos analogRead analogReference analogWrite asin atan atan2 attached attachInterrupt autoscroll available begin beginPacket beginTransmission BIN bitClear bitRead bitSet bitWrite blink ceil CHANGE clear close connect connected constrain cos createChar cursor DEC DEFAULT degrees delay delayMicroseconds detachInterrupt digitalRead digitalWrite direction display EEPROM endPacket endTransmission Ethernet EthernetClient EthernetServer exists exp EXTERNAL FALLING File FILE_READ FILE_WRITE floor flush HALF_PI HEX HIGH highByte home INPUT INPUT_PULLUP INTERNAL INTERNAL1V1 INTERNAL2V56 interrupts IPAddress isListening Keyboard leftToRight LiquidCrystal listen LOW lowByte LSBFIRST map max micros millis min mkdir Mouse MSBFIRST NewSoftSerial noAutoscroll noBlink noCursor noDisplay noInterrupts noTone OCT onReceive onRequest open OUTPUT overflow parsePacket peek pinMode position pow print println pulseIn radians randomSeed read readMicroseconds receive remoteIP remotePort remove requestFrom rightToLeft RISING rmdir round scrollDisplayLeft scrollDisplayRight SD seek send Serial Serial1 Serial2 Serial3 Servo setBitOrder setClockDivider setCursor setDataMode setSpeed shiftIn shiftOut sin size SoftwareSerial speed SPI SPI_CLOCK_DIV128 SPI_CLOCK_DIV16 SPI_CLOCK_DIV2 SPI_CLOCK_DIV32 SPI_CLOCK_DIV4 SPI_CLOCK_DIV64 SPI_CLOCK_DIV8 SPI_MODE0 SPI_MODE1 SPI_MODE2 SPI_MODE3 sqrt status step Stepper stop stream tan tone transfer TWO_PI version Wire write writeMicroseconds

TYPE WORDS

boolean byte int16_t int32_t int64_t prog_char prog_int16_t prog_int32_t prog_int64_t prog_int8_t prog_uchar prog_uint16_t prog_uint32_t prog_uint64_t prog_uint8_t prog_void PROGMEM String uint16_t uint32_t uint64_t uint8_t word

I have updated the language additions to include keywords used in IDE version 1.0.3. Install instructions remain the same as previous reply.

INSTRUCTIONS

abs accept acos analogRead analogReference analogWrite asin atan atan2 attach attached attachInterrupt autoscroll available begin beginPacket beginTransmission bit bitClear bitRead bitSet bitWrite blink blinkVersion BSSID callbackFunction ceil char class clear click Client close connect connected const constrain cos createChar cursor degrees delay delayMicroseconds detach detachInterrupt digitalRead digitalWrite direction disconnect display double EEPROM encryptionType end endPacket endTransmission Ethernet EthernetClient EthernetServer exists exp File find findUntil Firmata float floor flush gatewayIP getResult getSocket highByte home int int16_t int32_t int64_t interrupts IPAddress isListening isPressed Keyboard leftToRight LiquidCrystal listen localIP log long loop lowByte macAddress map max micros millis min mkdir Mouse move NewSoftSerial noAutoscroll noBlink noCursor noDisplay noInterrupts noTone null onReceive onRequest open overflow parseFloat parseInt parsePacket peek pinMode position press print printFirmwareVersion println printVersion private processInput prog_char prog_int16_t prog_int32_t prog_int64_t prog_int8_t prog_uchar prog_uint16_t prog_uint32_t prog_uint64_t prog_uint8_t prog_void PROGMEM protected public pulseIn radians random randomSeed read readBytes readBytesUntil readMicroseconds receive register release releaseAll remoteIP remotePort remove requestFrom rightToLeft rmdir round RSSI scrollDisplayLeft scrollDisplayRight SD seek send sendAnalog sendDigital sendDigitalPort sendDigitalPortPair sendString sendSysex Serial Serial1 Serial2 Serial3 Server Servo setBitOrder setClockDivider setCursor setDataMode setFirmwareNameAndVersion setFirmwareVersion setSpeed setTimeout setup shiftIn shiftOut short signed sin size speed SPI sq sqrt SSID static status step Stepper stop stringCallbackFunction subnetMask sysexCallbackFunction systemResetCallbackFunction tan tone transfer uint16_t uint32_t uint64_t uint8_t unsigned version void WiFi WiFiClient WiFiServer Wire write writeMicroseconds

TYPES

ANALOG_MESSAGE ANALOG_PORT BIN CHANGE DEC DEFAULT DIGITAL_MESSAGE END_SYSEX EXTERNAL FALLING FILE_READ FILE_WRITE HALF_PI HEX HIGH INPUT INPUT_PULLUP INTERNAL INTERNAL1V1 INTERNAL2V56 LOW LSBFIRST MAX_DATA_BYTES MSBFIRST OCT OUTPUT PI PWM REPORT_ANALOG REPORT_DIGITAL REPORT_VERSION RISING SERIAL_5E1 SERIAL_5E2 SERIAL_5N1 SERIAL_5N2 SERIAL_5O1 SERIAL_5O2 SERIAL_6E1 SERIAL_6E2 SERIAL_6N1 SERIAL_6N2 SERIAL_6O1 SERIAL_6O2 SERIAL_7E1 SERIAL_7E2 SERIAL_7N1 SERIAL_7N2 SERIAL_7O1 SERIAL_7O2 SERIAL_8E1 SERIAL_8E2 SERIAL_8N1 SERIAL_8N2 SERIAL_8O1 SERIAL_8O2 SET_PIN_MODE SPI_CLOCK_DIV128 SPI_CLOCK_DIV16 SPI_CLOCK_DIV2 SPI_CLOCK_DIV32 SPI_CLOCK_DIV4 SPI_CLOCK_DIV64 SPI_CLOCK_DIV8 SPI_MODE0 SPI_MODE1 SPI_MODE2 SPI_MODE3 START_SYSEX SYSTEM_RESET TOTAL_ANALOG_PINS TOTAL_DIGITAL_PINS TOTAL_PORTS TWO_PI

Thanks Riva, this is a welcome addiiton for those of us that use NPP.

And the install was delightfully simple: after downloading the xml file linked in the first post, in NPP I opened the 'Defined Language dialog' (under the View menu option), clicked "Import" and navigated to the downloaded "userDefineLang.xml" file

Very nice!

Hi mem,
The most compleat intergration is to follow the instructions in post 13 but use the values in post 14 as could not get everthing working properly using the xml method. I would be better to start a new thread as this one is a bit confusing now but this will have to wait till I get home in a few days.

I would be interested to know why the xml approach is not working as you want. The NPP user-defined language seems easier for users to install and more flexible for those of use that want to switch between Arduino colouring and straight C++. Please do post a link if you start a new thread on this topic.

This thread has been superseded by this Notepad++ User Defined Language for Arduino

Updated to correct links from old forum to the post in this forum.