notepad-plus-plus/lexilla/test/examples/dart/AllStyles.dart.styled
Christian Grasser e85c354135 Update to scintilla 5.5.7 & Lexilla 5.4.5
Release 5.5.7 (https://www.scintilla.org/scintilla557.zip)

Released 8 June 2025

1. Add SCI_SCROLLVERTICAL method to restore view position and maintain it while performing line wrapping.
2. Add SC_UNDO_SELECTION_HISTORY_SCROLL flag to SCI_SETUNDOSELECTIONHISTORY which controls whether undo and redo restore vertical scroll position.
3. Tweak SC_MARK_BAR to be slightly wider by using next higher whole pixel instead of next lower for margin width / 3.
4. Scale images in autocompletion lists with SCI_AUTOCSETIMAGESCALE to match high DPI screens. Initially only on GTK and Qt.
5. Fix wrapping bug for UTF-8 where \r\n could wrap between the characters. Notepad++ Pull Request #16373.
6. Fix crash during painting when scroll bars changed. Bug #2481.
7. On GTK, reset vertical scroll bar synchronously in SCI_SETDOCPOINTER to fix bug where scroll position not restored in non-wrap mode. Bug #2416.
8. On GTK, fix IME problem when tentative composition interfered with delete surrounding. Feature #1476.
9. On GTK, update IME cursor position inside retrieve surrounding to better position candidate window. Feature #1488.

Release 5.4.5 (https://www.scintilla.org/lexilla545.zip)

Released 8 June 2025

1. Dart: Add error state SCE_DART_STRINGEOL for unterminated string. Pull request #315.
2. Makefile: Add a keyword list to makefile lexer to highlight GNU Make directives like 'ifdef' and 'vpath' as SCE_MAKE_PREPROCESSOR since these are similar to NMAKE directives like '!IFDEF'.
3. Nix: Add error state SCE_NIX_STRINGEOL for unterminated string. Pull request #315.
4. TOML: Add error state SCE_TOML_STRINGEOL for unterminated string. Pull request #315.
5. Zig: Add error state SCE_ZIG_STRINGEOL for unterminated string. Pull request #315.

Close #16649
2025-06-13 15:12:33 +02:00

340 lines
14 KiB
Plaintext

{1}// coding:utf-8
{0}
{24}void{0} {14}main{16}(){0} {16}{{0}
{14}print{16}({5}'Hello, World!'{16});{0}
{16}}{0}
{23}var{0} {14}name{0} {16}={0} {5}'Voyager I'{16};{0}
{23}var{0} {14}url{0} {16}={0} {5}'url'{0}
{23}var{0} {14}year{0} {16}={0} {20}1977{16};{0}
{23}var{0} {14}antennaDiameter{0} {16}={0} {20}3.7{16};{0}
{23}var{0} {14}flybyObjects{0} {16}={0} {16}[{5}'Jupiter'{16},{0} {5}'Saturn'{16},{0} {5}'Uranus'{16},{0} {5}'Neptune'{16}];{0}
{23}var{0} {14}image{0} {16}={0} {16}{{0}
{5}'tags'{16}:{0} {16}[{5}'saturn'{16}],{0}
{21}url{16}:{0} {5}'//path/to/saturn.jpg'{0}
{16}};{0}
{23}if{0} {16}({14}year{0} {16}>={0} {20}2001{16}){0} {16}{{0}
{14}print{16}({5}'21st century'{16});{0}
{16}}{0} {23}else{0} {23}if{0} {16}({14}year{0} {16}>={0} {20}1901{16}){0} {16}{{0}
{14}print{16}({5}'20th century'{16});{0}
{16}}{0}
{23}for{0} {16}({23}final{0} {14}object{0} {23}in{0} {14}flybyObjects{16}){0} {16}{{0}
{14}print{16}({14}object{16});{0}
{16}}{0}
{23}for{0} {16}({24}int{0} {14}month{0} {16}={0} {20}1{16};{0} {14}month{0} {16}<={0} {20}12{16};{0} {14}month{16}++){0} {16}{{0}
{14}print{16}({14}month{16});{0}
{16}}{0}
{23}while{0} {16}({14}year{0} {16}<{0} {20}2016{16}){0} {16}{{0}
{14}year{0} {16}+={0} {20}1{16};{0}
{16}}{0}
{14}flybyObjects{16}.{14}where{16}(({14}name{16}){0} {16}=>{0} {14}name{16}.{14}contains{16}({5}'turn'{16})).{14}forEach{16}({14}print{16});{0}
{1}// This is a normal, one-line comment.
{0}
{2}/// This is a documentation comment, used to document libraries,
/// classes, and their members. Tools like IDEs and dartdoc treat
/// doc comments specially.
{0}
{3}/* Comments like these are also supported. */{0}
{4}/** Comment
block doc */{0}
{1}// Importing core libraries
{23}import{0} {5}'dart:math'{16};{0}
{1}// Importing libraries from external packages
{23}import{0} {5}'package:test/test.dart'{16};{0}
{1}// Importing files
{23}import{0} {5}'path/to/my_other_file.dart'{16};{0}
{23}class{0} {26}Spacecraft{0} {16}{{0}
{25}String{0} {14}name{16};{0}
{25}DateTime{16}?{0} {14}launchDate{16};{0}
{1}// Read-only non-final property
{0} {24}int{16}?{0} {23}get{0} {14}launchYear{0} {16}=>{0} {14}launchDate{16}?.{14}year{16};{0}
{1}// Constructor, with syntactic sugar for assignment to members.
{0} {26}Spacecraft{16}({23}this{16}.{14}name{16},{0} {23}this{16}.{14}launchDate{16}){0} {16}{{0}
{1}// Initialization code goes here.
{0} {16}}{0}
{1}// Named constructor that forwards to the default one.
{0} {26}Spacecraft{16}.{14}unlaunched{16}({25}String{0} {14}name{16}){0} {16}:{0} {23}this{16}({14}name{16},{0} {23}null{16});{0}
{1}// Method.
{0} {24}void{0} {14}describe{16}(){0} {16}{{0}
{14}print{16}({5}'Spacecraft: {17}${15}name{5}'{16});{0}
{1}// Type promotion doesn't work on getters.
{0} {23}var{0} {14}launchDate{0} {16}={0} {23}this{16}.{14}launchDate{16};{0}
{23}if{0} {16}({14}launchDate{0} {16}!={0} {23}null{16}){0} {16}{{0}
{24}int{0} {14}years{0} {16}={0} {25}DateTime{16}.{14}now{16}().{14}difference{16}({14}launchDate{16}).{14}inDays{0} {16}~/{0} {20}365{16};{0}
{14}print{16}({5}'Launched: {17}${15}launchYear{5} ({17}${15}years{5} years ago)'{16});{0}
{16}}{0} {23}else{0} {16}{{0}
{14}print{16}({5}'Unlaunched'{16});{0}
{16}}{0}
{16}}{0}
{16}}{0}
{23}var{0} {14}voyager{0} {16}={0} {26}Spacecraft{16}({5}'Voyager I'{16},{0} {25}DateTime{16}({20}1977{16},{0} {20}9{16},{0} {20}5{16}));{0}
{14}voyager{16}.{14}describe{16}();{0}
{23}var{0} {14}voyager3{0} {16}={0} {26}Spacecraft{16}.{14}unlaunched{16}({5}'Voyager III'{16});{0}
{14}voyager3{16}.{14}describe{16}();{0}
{23}enum{0} {14}PlanetType{0} {16}{{0} {14}terrestrial{16},{0} {14}gas{16},{0} {14}ice{0} {16}}{0}
{2}/// Enum that enumerates the different planets in our solar system
/// and some of their properties.
{23}enum{0} {14}Planet{0} {16}{{0}
{14}mercury{16}({21}planetType{16}:{0} {14}PlanetType{16}.{14}terrestrial{16},{0} {21}moons{16}:{0} {20}0{16},{0} {21}hasRings{16}:{0} {23}false{16}),{0}
{14}venus{16}({21}planetType{16}:{0} {14}PlanetType{16}.{14}terrestrial{16},{0} {21}moons{16}:{0} {20}0{16},{0} {21}hasRings{16}:{0} {23}false{16}),{0}
{1}// ···
{0} {14}uranus{16}({21}planetType{16}:{0} {14}PlanetType{16}.{14}ice{16},{0} {21}moons{16}:{0} {20}27{16},{0} {21}hasRings{16}:{0} {23}true{16}),{0}
{14}neptune{16}({21}planetType{16}:{0} {14}PlanetType{16}.{14}ice{16},{0} {21}moons{16}:{0} {20}14{16},{0} {21}hasRings{16}:{0} {23}true{16});{0}
{2}/// A constant generating constructor
{0} {23}const{0} {14}Planet{16}({0}
{16}{{23}required{0} {23}this{16}.{14}planetType{16},{0} {23}required{0} {23}this{16}.{14}moons{16},{0} {23}required{0} {23}this{16}.{14}hasRings{16}});{0}
{2}/// All instance variables are final
{0} {23}final{0} {14}PlanetType{0} {14}planetType{16};{0}
{23}final{0} {24}int{0} {14}moons{16};{0}
{23}final{0} {24}bool{0} {14}hasRings{16};{0}
{2}/// Enhanced enums support getters and other methods
{0} {24}bool{0} {23}get{0} {14}isGiant{0} {16}=>{0}
{14}planetType{0} {16}=={0} {14}PlanetType{16}.{14}gas{0} {16}||{0} {14}planetType{0} {16}=={0} {14}PlanetType{16}.{14}ice{16};{0}
{16}}{0}
{23}final{0} {14}yourPlanet{0} {16}={0} {14}Planet{16}.{14}earth{16};{0}
{23}if{0} {16}(!{14}yourPlanet{16}.{14}isGiant{16}){0} {16}{{0}
{14}print{16}({5}'Your planet is not a "giant planet".'{16});{0}
{16}}{0}
{23}mixin{0} {14}Piloted{0} {16}{{0}
{24}int{0} {14}astronauts{0} {16}={0} {20}1{16};{0}
{24}void{0} {14}describeCrew{16}(){0} {16}{{0}
{14}print{16}({5}'Number of astronauts: {17}${15}astronauts{5}'{16});{0}
{16}}{0}
{16}}{0}
{23}const{0} {14}oneSecond{0} {16}={0} {25}Duration{16}({21}seconds{16}:{0} {20}1{16});{0}
{1}// ···
{25}Future{16}<{24}void{16}>{0} {14}printWithDelay{16}({25}String{0} {14}message{16}){0} {23}async{0} {16}{{0}
{23}await{0} {25}Future{16}.{14}delayed{16}({14}oneSecond{16});{0}
{14}print{16}({14}message{16});{0}
{16}}{0}
{25}Future{16}<{24}void{16}>{0} {14}printWithDelay{16}({25}String{0} {14}message{16}){0} {16}{{0}
{23}return{0} {25}Future{16}.{14}delayed{16}({14}oneSecond{16}).{14}then{16}(({14}_{16}){0} {16}{{0}
{14}print{16}({14}message{16});{0}
{16}});{0}
{16}}{0}
{25}Future{16}<{24}void{16}>{0} {14}createDescriptions{16}({25}Iterable{16}<{25}String{16}>{0} {14}objects{16}){0} {23}async{0} {16}{{0}
{23}for{0} {16}({23}final{0} {14}object{0} {23}in{0} {14}objects{16}){0} {16}{{0}
{23}try{0} {16}{{0}
{23}var{0} {14}file{0} {16}={0} {25}File{16}({5}'{17}${15}object{5}.txt'{16});{0}
{23}if{0} {16}({23}await{0} {14}file{16}.{14}exists{16}()){0} {16}{{0}
{23}var{0} {14}modified{0} {16}={0} {23}await{0} {14}file{16}.{14}lastModified{16}();{0}
{14}print{16}({0}
{5}'File for {17}${15}object{5} already exists. It was modified on {17}${15}modified{5}.'{16});{0}
{23}continue{16};{0}
{16}}{0}
{23}await{0} {14}file{16}.{14}create{16}();{0}
{23}await{0} {14}file{16}.{14}writeAsString{16}({5}'Start describing {17}${15}object{5} in this file.'{16});{0}
{16}}{0} {23}on{0} {25}IOException{0} {23}catch{0} {16}({14}e{16}){0} {16}{{0}
{14}print{16}({5}'Cannot create description for {17}${15}object{5}: {17}${15}e{5}'{16});{0}
{16}}{0}
{16}}{0}
{16}}{0}
{25}Stream{16}<{25}String{16}>{0} {14}report{16}({26}Spacecraft{0} {14}craft{16},{0} {25}Iterable{16}<{25}String{16}>{0} {14}objects{16}){0} {23}async{16}*{0} {16}{{0}
{23}for{0} {16}({23}final{0} {14}object{0} {23}in{0} {14}objects{16}){0} {16}{{0}
{23}await{0} {25}Future{16}.{14}delayed{16}({14}oneSecond{16});{0}
{23}yield{0} {5}'{17}${{14}craft{16}.{14}name{17}}{5} flies by {17}${15}object{5}'{16};{0}
{16}}{0}
{16}}{0}
{25}Future{16}<{24}void{16}>{0} {14}describeFlybyObjects{16}({25}List{16}<{25}String{16}>{0} {14}flybyObjects{16}){0} {23}async{0} {16}{{0}
{23}try{0} {16}{{0}
{23}for{0} {16}({23}final{0} {14}object{0} {23}in{0} {14}flybyObjects{16}){0} {16}{{0}
{23}var{0} {14}description{0} {16}={0} {23}await{0} {25}File{16}({5}'{17}${15}object{5}.txt'{16}).{14}readAsString{16}();{0}
{14}print{16}({14}description{16});{0}
{16}}{0}
{16}}{0} {23}on{0} {25}IOException{0} {23}catch{0} {16}({14}e{16}){0} {16}{{0}
{14}print{16}({5}'Could not describe object: {17}${15}e{5}'{16});{0}
{16}}{0} {23}finally{0} {16}{{0}
{14}flybyObjects{16}.{14}clear{16}();{0}
{16}}{0}
{16}}{0}
{23}class{0} {14}Television{0} {16}{{0}
{2}/// Use [turnOn] to turn the power on instead.
{0} {22}@Deprecated{16}({5}'Use turnOn instead'{16}){0}
{24}void{0} {14}activate{16}(){0} {16}{{0}
{14}turnOn{16}();{0}
{16}}{0}
{2}/// Turns the TV's power on.
{0} {24}void{0} {14}turnOn{16}(){0} {16}{...}{0}
{1}// ···
{16}}{0}
{25}String{16}?{0} {14}name{0} {1}// Nullable type. Can be `null` or string.
{0}
{25}String{0} {14}name{0} {1}// Non-nullable type. Cannot be `null` but can be string.
{0}
{2}/// A domesticated South American camelid (Lama glama).
///
/// Andean cultures have used llamas as meat and pack
/// animals since pre-Hispanic times.
///
/// Just like any other animal, llamas need to eat,
/// so don't forget to [feed] them some [Food].
{23}class{0} {14}Llama{0} {16}{{0}
{25}String{16}?{0} {14}name{16};{0}
{4}/** Feeds your llama [food].
/
/ The typical llama eats one bale of hay per week. **/{0}
{24}void{0} {14}feed{16}({14}Food{0} {14}food{16}){0} {16}{{0}
{1}// ...
{0} {16}}{0}
{2}/// Exercises your llama with an [activity] for
{0} {2}/// [timeLimit] minutes.
{0} {24}void{0} {14}exercise{16}({14}Activity{0} {14}activity{16},{0} {24}int{0} {14}timeLimit{16}){0} {16}{{0}
{1}// ...
{0} {16}}{0}
{16}}{0}
{23}import{0} {5}'package:lib1/lib1.dart'{16};{0}
{23}import{0} {5}'package:lib2/lib2.dart'{0} {23}as{0} {14}lib2{16};{0}
{1}// Import only foo.
{23}import{0} {5}'package:lib1/lib1.dart'{0} {23}show{0} {14}foo{16};{0}
{1}// Import all names EXCEPT foo.
{23}import{0} {5}'package:lib2/lib2.dart'{0} {23}hide{0} {14}foo{16};{0}
{14}print{16}({18}#mysymbol{16});{0}
{25}Symbol{0} {14}symbol{0} {16}={0} {18}#myMethod{16};{0}
{25}Symbol{0} {14}symbol2{0} {16}={0} {19}#<{16};{0}
{25}Symbol{0} {14}symbol2{0} {16}={0} {18}#void{16};{0}
{23}var{0} {14}x{0} {16}={0} {20}1{16};{0}
{23}var{0} {14}hex{0} {16}={0} {20}0xDEADBEEF{16};{0}
{23}var{0} {14}y{0} {16}={0} {20}1.1{16};{0}
{23}var{0} {14}exponents{0} {16}={0} {20}1.42e5{16};{0}
{23}var{0} {14}s1{0} {16}={0} {5}'Single quotes work well for string literals.'{16};{0}
{23}var{0} {14}s2{0} {16}={0} {6}"Double quotes work just as well."{16};{0}
{23}var{0} {14}s3{0} {16}={0} {5}'It{13}\'{5}s easy to escape the string delimiter.'{16};{0}
{23}var{0} {14}s4{0} {16}={0} {6}"It's even easier to use the other delimiter."{16};{0}
{23}var{0} {14}s{0} {16}={0} {5}'string interpolation'{16};{0}
{23}assert{16}({5}'Dart has {17}${15}s{5}, which is very handy.'{0} {16}=={0}
{5}'Dart has string interpolation, '{0}
{5}'which is very handy.'{16});{0}
{23}assert{16}({5}'That deserves all caps. '{0}
{5}'{17}${{14}s{16}.{14}toUpperCase{16}(){17}}{5} is very handy!'{0} {16}=={0}
{5}'That deserves all caps. '{0}
{5}'STRING INTERPOLATION is very handy!'{16});{0}
{23}var{0} {14}s1{0} {16}={0} {5}'String '{0}
{5}'concatenation'{0}
{6}" works even over line breaks."{16};{0}
{23}assert{16}({14}s1{0} {16}=={0}
{5}'String concatenation works even over '{0}
{5}'line breaks.'{16});{0}
{23}var{0} {14}s2{0} {16}={0} {5}'The + operator '{0} {16}+{0} {5}'works, as well.'{16};{0}
{23}assert{16}({14}s2{0} {16}=={0} {5}'The + operator works, as well.'{16});{0}
{23}var{0} {14}s1{0} {16}={0} {7}'''
You can create
multi-line strings like this one.
'''{16};{0}
{23}var{0} {14}s2{0} {16}={0} {8}"""This is also a
multi-line string."""{16};{0}
{23}var{0} {14}s{0} {16}={0} {9}r'In a raw string, not even \n gets special treatment.'{16};{0}
{23}var{0} {20}2{0} {16}={0} {10}r"In a raw string, not even \n gets special treatment."{16};{0}
{23}var{0} {14}s1{0} {16}={0} {11}r'''
You can create
multi-line strings like this one.
'''{16};{0}
{23}var{0} {14}s2{0} {16}={0} {12}r"""This is also a
multi-line string."""{16};{0}
{23}var{0} {14}record{0} {16}={0} {16}({5}'first'{16},{0} {21}a{16}:{0} {20}2{16},{0} {21}b{16}:{0} {23}true{16},{0} {5}'last'{16});{0}
{23}var{0} {14}record{0} {16}={0} {16}({5}'first'{16},{0} {21}a{16}:{0} {20}2{16},{0} {21}b{16}:{0} {23}true{16},{0} {5}'last'{16});{0}
{14}print{16}({14}record{16}.{14}$1{16});{0} {1}// Prints 'first'
{14}print{16}({14}record{16}.{14}a{16});{0} {1}// Prints 2
{14}print{16}({14}record{16}.{14}b{16});{0} {1}// Prints true
{14}print{16}({14}record{16}.{14}$2{16});{0} {1}// Prints 'last'
{0}
{16}({{25}String{0} {14}name{16},{0} {24}int{0} {14}age{16}}){0} {14}userInfo{16}({25}Map{16}<{25}String{16},{0} {24}dynamic{16}>{0} {14}json{16}){0}
{1}// ···
// Destructures using a record pattern with named fields:
{23}final{0} {16}(:{14}name{16},{0} {16}:{14}age{16}){0} {16}={0} {14}userInfo{16}({14}json{16});{0}
{23}var{0} {14}list{0} {16}={0} {16}[{20}1{16},{0} {20}2{16},{0} {20}3{16}];{0}
{23}var{0} {14}list{0} {16}={0} {16}[{0}
{5}'Car'{16},{0}
{5}'Boat'{16},{0}
{5}'Plane'{16},{0}
{16}];{0}
{23}var{0} {14}halogens{0} {16}={0} {16}{{5}'fluorine'{16},{0} {5}'chlorine'{16},{0} {5}'bromine'{16},{0} {5}'iodine'{16},{0} {5}'astatine'{16}};{0}
{23}var{0} {14}nobleGases{0} {16}={0} {16}{{0}
{20}2{16}:{0} {5}'helium'{16},{0}
{20}10{16}:{0} {5}'neon'{16},{0}
{20}18{16}:{0} {5}'argon'{16},{0}
{16}};{0}
{23}var{0} {14}s{0} {16}={0} {8}"""This is also a
{17}${{14}foo{16}({0}
{6}"{17}${15}bar{6}"{0}
{16}){17}}{8}
multi-line string."""{16};{0}
{23}var{0} {14}s1{0} {16}={0} {8}"""multi
line
{13}\n{8}
strings
"""{16};{0}
{23}var{0} {14}s2{0} {16}={0} {8}"""multi-line
{17}${15}x{8}
strings
"""{16};{0}
{23}var{0} {14}s3{0} {16}={0} {8}"""multi-line
{17}${{14}x{17}}{8}
strings
"""{16};{0}
{23}var{0} {14}s1{0} {16}={0} {27}'Unterminated string;
{23}var{0} {14}s2{0} {16}={0} {27}"Unterminated string;
{23}var{0} {14}s3{0} {16}={0} {27}r'Unterminated raw string;
{23}var{0} {14}s4{0} {16}={0} {27}r'Unterminated raw string;