mirror of
				https://github.com/sharkdp/bat.git
				synced 2025-10-31 07:04:04 +00:00 
			
		
		
		
	Merge branch 'master' into patch-1
This commit is contained in:
		
							
								
								
									
										3
									
								
								.gitmodules
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.gitmodules
									
									
									
									
										vendored
									
									
								
							| @@ -266,6 +266,9 @@ | ||||
| [submodule "assets/syntaxes/02_Extra/Idris2"] | ||||
| 	path = assets/syntaxes/02_Extra/Idris2 | ||||
| 	url = https://github.com/buzden/sublime-syntax-idris2 | ||||
| [submodule "assets/syntaxes/02_Extra/GDScript-sublime"] | ||||
| 	path = assets/syntaxes/02_Extra/GDScript-sublime | ||||
| 	url = https://github.com/beefsack/GDScript-sublime | ||||
| [submodule "assets/syntaxes/02_Extra/sublime-odin"] | ||||
| 	path = assets/syntaxes/02_Extra/sublime-odin | ||||
| 	url = https://github.com/odin-lang/sublime-odin | ||||
|   | ||||
| @@ -10,6 +10,8 @@ | ||||
| - Prevent `--list-themes` from outputting default theme info to stdout when it is piped, see #3189 (@einfachIrgendwer0815) | ||||
| - Rename some submodules to fix Dependabot submodule updates, see issue #3198 and PR #3201 (@victor-gp) | ||||
| - Make highlight tests fail when new syntaxes don't have fixtures PR #3255 (@dan-hipschman) | ||||
| - Fix crash for multibyte characters in file path, see issue #3230 and PR #3245 (@HSM95) | ||||
| - Add missing mappings for various bash/zsh files, see PR #3262 (@AdamGaskins) | ||||
|  | ||||
| ## Other | ||||
|  | ||||
| @@ -26,6 +28,7 @@ | ||||
| - Map `ndjson` extension to JSON syntax, see #3209 (@keith-hall) | ||||
| - Map files with `csproj`, `vbproj`, `props` and `targets` extensions to XML syntax, see #3213 (@keith-hall) | ||||
| - Add debsources syntax to highlight `/etc/apt/sources.list` files, see #3215 (@keith-hall) | ||||
| - Add syntax definition and test file for GDScript highlighting, see #3236 (@chetanjangir0) | ||||
| - Add syntax test file for Odin highlighting, see #3241 (@chetanjangir0) | ||||
|  | ||||
| ## Themes | ||||
|   | ||||
							
								
								
									
										7
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										7
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
								
							| @@ -153,6 +153,7 @@ dependencies = [ | ||||
|  "terminal-colorsaurus", | ||||
|  "thiserror 2.0.11", | ||||
|  "toml", | ||||
|  "unicode-segmentation", | ||||
|  "unicode-width 0.1.14", | ||||
|  "wait-timeout", | ||||
|  "walkdir", | ||||
| @@ -1678,6 +1679,12 @@ version = "1.0.14" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" | ||||
|  | ||||
| [[package]] | ||||
| name = "unicode-segmentation" | ||||
| version = "1.12.0" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" | ||||
|  | ||||
| [[package]] | ||||
| name = "unicode-width" | ||||
| version = "0.1.14" | ||||
|   | ||||
| @@ -69,6 +69,7 @@ bytesize = { version = "1.3.0" } | ||||
| encoding_rs = "0.8.35" | ||||
| execute = { version = "0.2.13", optional = true } | ||||
| terminal-colorsaurus = "0.4" | ||||
| unicode-segmentation = "1.12.0" | ||||
|  | ||||
| [dependencies.git2] | ||||
| version = "0.20" | ||||
|   | ||||
							
								
								
									
										2
									
								
								assets/syntaxes/02_Extra/Apache
									
									
									
									
										vendored
									
									
								
							
							
								
								
								
								
								
							
						
						
									
										2
									
								
								assets/syntaxes/02_Extra/Apache
									
									
									
									
										vendored
									
									
								
							 Submodule assets/syntaxes/02_Extra/Apache updated: 163bc03ae8...cf6cefc51e
									
								
							
							
								
								
									
										1
									
								
								assets/syntaxes/02_Extra/GDScript-sublime
									
									
									
									
										vendored
									
									
										Submodule
									
								
							
							
								
								
								
								
								
							
						
						
									
										1
									
								
								assets/syntaxes/02_Extra/GDScript-sublime
									
									
									
									
										vendored
									
									
										Submodule
									
								
							 Submodule assets/syntaxes/02_Extra/GDScript-sublime added at 96f5dcf297
									
								
							
							
								
								
									
										2
									
								
								assets/syntaxes/02_Extra/PowerShell
									
									
									
									
										vendored
									
									
								
							
							
								
								
								
								
								
							
						
						
									
										2
									
								
								assets/syntaxes/02_Extra/PowerShell
									
									
									
									
										vendored
									
									
								
							 Submodule assets/syntaxes/02_Extra/PowerShell updated: c0372a1d2d...a08b55bf11
									
								
							
							
								
								
									
										2
									
								
								assets/themes/zenburn
									
									
									
									
										vendored
									
									
								
							
							
								
								
								
								
								
							
						
						
									
										2
									
								
								assets/themes/zenburn
									
									
									
									
										vendored
									
									
								
							 Submodule assets/themes/zenburn updated: 86d4ee7a1f...9c588ebc11
									
								
							| @@ -15,6 +15,7 @@ use content_inspector::ContentType; | ||||
|  | ||||
| use encoding_rs::{UTF_16BE, UTF_16LE}; | ||||
|  | ||||
| use unicode_segmentation::UnicodeSegmentation; | ||||
| use unicode_width::UnicodeWidthChar; | ||||
|  | ||||
| use crate::assets::{HighlightingAssets, SyntaxReferenceInSet}; | ||||
| @@ -388,14 +389,18 @@ impl<'a> InteractivePrinter<'a> { | ||||
|         handle: &mut OutputHandle, | ||||
|         content: &str, | ||||
|     ) -> Result<()> { | ||||
|         let mut content = content; | ||||
|         let content_width = self.config.term_width - self.get_header_component_indent_length(); | ||||
|         while content.len() > content_width { | ||||
|             let (content_line, remaining) = content.split_at(content_width); | ||||
|             self.print_header_component_with_indent(handle, content_line)?; | ||||
|             content = remaining; | ||||
|         if content.chars().count() <= content_width { | ||||
|             return self.print_header_component_with_indent(handle, content); | ||||
|         } | ||||
|         self.print_header_component_with_indent(handle, content) | ||||
|  | ||||
|         let mut content_graphemes: Vec<&str> = content.graphemes(true).collect(); | ||||
|         while content_graphemes.len() > content_width { | ||||
|             let (content_line, remaining) = content_graphemes.split_at(content_width); | ||||
|             self.print_header_component_with_indent(handle, content_line.join("").as_str())?; | ||||
|             content_graphemes = remaining.iter().cloned().collect(); | ||||
|         } | ||||
|         self.print_header_component_with_indent(handle, content_graphemes.join("").as_str()) | ||||
|     } | ||||
|  | ||||
|     fn highlight_regions_for_line<'b>( | ||||
|   | ||||
| @@ -2,4 +2,24 @@ | ||||
| "Bourne Again Shell (bash)" = [ | ||||
|     # used by lots of shells | ||||
|     "/etc/profile", | ||||
|  | ||||
|     "bashrc", | ||||
|     "*.bashrc", | ||||
|     "bash_profile", | ||||
|     "*.bash_profile", | ||||
|     "bash_login", | ||||
|     "*.bash_login", | ||||
|     "bash_logout", | ||||
|     "*.bash_logout", | ||||
|  | ||||
|     "zshrc", | ||||
|     "*.zshrc", | ||||
|     "zprofile", | ||||
|     "*.zprofile", | ||||
|     "zlogin", | ||||
|     "*.zlogin", | ||||
|     "zlogout", | ||||
|     "*.zlogout", | ||||
|     "zshenv", | ||||
|     "*.zshenv" | ||||
| ] | ||||
|   | ||||
							
								
								
									
										0
									
								
								tests/examples/test.A—B가
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								tests/examples/test.A—B가
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -1600,6 +1600,17 @@ oken | ||||
|         .stderr(""); | ||||
| } | ||||
|  | ||||
| #[test] | ||||
| fn header_narrow_terminal_with_multibyte_chars() { | ||||
|     bat() | ||||
|         .arg("--terminal-width=30") | ||||
|         .arg("--decorations=always") | ||||
|         .arg("test.A—B가") | ||||
|         .assert() | ||||
|         .success() | ||||
|         .stderr(""); | ||||
| } | ||||
|  | ||||
| #[test] | ||||
| #[cfg(feature = "git")] // Expected output assumes git is enabled | ||||
| fn header_default() { | ||||
|   | ||||
							
								
								
									
										71
									
								
								tests/syntax-tests/highlighted/GDScript/test.gd
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										71
									
								
								tests/syntax-tests/highlighted/GDScript/test.gd
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,71 @@ | ||||
| [38;2;249;38;114mextends[0m[3;4;38;2;166;226;46m Node[0m | ||||
|  | ||||
| [3;38;2;102;217;239msignal[0m[38;2;248;248;242m [0m[38;2;166;226;46mcustom_signal[0m[38;2;248;248;242m([0m[3;38;2;253;151;31mparam[0m[38;2;248;248;242m)[0m | ||||
|  | ||||
| [3;38;2;102;217;239mconst[0m[38;2;248;248;242m [0m[38;2;255;255;255mPI[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;190;132;255m3.14159[0m | ||||
|  | ||||
| [3;38;2;102;217;239mvar[0m[38;2;248;248;242m [0m[38;2;255;255;255muntyped_var[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mHello, World![0m[38;2;230;219;116m"[0m | ||||
| [3;38;2;102;217;239mvar[0m[38;2;248;248;242m [0m[38;2;255;255;255mtyped_int[0m[38;2;248;248;242m: [0m[3;38;2;102;217;239mint[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;190;132;255m42[0m | ||||
| [3;38;2;102;217;239mvar[0m[38;2;248;248;242m [0m[38;2;255;255;255mtyped_float[0m[38;2;248;248;242m: [0m[3;38;2;102;217;239mfloat[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;190;132;255m3.14[0m | ||||
| [3;38;2;102;217;239mvar[0m[38;2;248;248;242m [0m[38;2;255;255;255mtyped_string[0m[38;2;248;248;242m: [0m[3;38;2;102;217;239mString[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mGDScript Test[0m[38;2;230;219;116m"[0m | ||||
| [3;38;2;102;217;239mvar[0m[38;2;248;248;242m [0m[38;2;255;255;255mtyped_array[0m[38;2;248;248;242m: [0m[3;38;2;102;217;239mArray[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [[0m[38;2;190;132;255m1[0m[38;2;248;248;242m, [0m[38;2;190;132;255m2[0m[38;2;248;248;242m, [0m[38;2;190;132;255m3[0m[38;2;248;248;242m, [0m[38;2;190;132;255m4[0m[38;2;248;248;242m][0m | ||||
| [3;38;2;102;217;239mvar[0m[38;2;248;248;242m [0m[38;2;255;255;255mtyped_dict[0m[38;2;248;248;242m: [0m[3;38;2;102;217;239mDictionary[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m[38;2;230;219;116m"[0m[38;2;230;219;116mkey[0m[38;2;230;219;116m"[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mvalue[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mnumber[0m[38;2;230;219;116m"[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[38;2;190;132;255m100[0m[38;2;248;248;242m}[0m | ||||
|  | ||||
| [38;2;249;38;114monready[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mvar[0m[38;2;248;248;242m [0m[38;2;255;255;255mlabel[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m $Label[0m | ||||
|  | ||||
| [3;38;2;102;217;239mfunc[0m[38;2;248;248;242m [0m[38;2;166;226;46msay_hello[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114m->[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mvoid[0m[38;2;248;248;242m:[0m | ||||
| [38;2;248;248;242m	[0m[38;2;248;248;242mprint[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mHello from GDScript![0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m | ||||
|  | ||||
| [3;38;2;102;217;239mfunc[0m[38;2;248;248;242m [0m[38;2;166;226;46madd_numbers[0m[38;2;248;248;242m([0m[3;38;2;253;151;31ma[0m[38;2;248;248;242m: [0m[3;38;2;253;151;31mint[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[3;38;2;253;151;31mb[0m[38;2;248;248;242m: [0m[3;38;2;253;151;31mint[0m[38;2;248;248;242m = 10[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114m->[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mint[0m[38;2;248;248;242m:[0m | ||||
| [38;2;248;248;242m	[0m[38;2;249;38;114mreturn[0m[38;2;248;248;242m a [0m[38;2;249;38;114m+[0m[38;2;248;248;242m b[0m | ||||
|  | ||||
| [3;38;2;102;217;239mfunc[0m[38;2;248;248;242m [0m[38;2;166;226;46mprocess_value[0m[38;2;248;248;242m([0m[3;38;2;253;151;31mvalue[0m[38;2;248;248;242m: [0m[3;38;2;253;151;31mint[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114m->[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mString[0m[38;2;248;248;242m:[0m | ||||
| [38;2;248;248;242m	[0m[38;2;249;38;114mif[0m[38;2;248;248;242m value [0m[38;2;249;38;114m<[0m[38;2;248;248;242m [0m[38;2;190;132;255m0[0m[38;2;248;248;242m:[0m | ||||
| [38;2;248;248;242m		[0m[38;2;249;38;114mreturn[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mNegative[0m[38;2;230;219;116m"[0m | ||||
| [38;2;248;248;242m	[0m[38;2;249;38;114melif[0m[38;2;248;248;242m value [0m[38;2;249;38;114m==[0m[38;2;248;248;242m [0m[38;2;190;132;255m0[0m[38;2;248;248;242m:[0m | ||||
| [38;2;248;248;242m		[0m[38;2;249;38;114mreturn[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mZero[0m[38;2;230;219;116m"[0m | ||||
| [38;2;248;248;242m	[0m[38;2;249;38;114melse[0m[38;2;248;248;242m:[0m | ||||
| [38;2;248;248;242m		[0m[38;2;249;38;114mreturn[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mPositive[0m[38;2;230;219;116m"[0m | ||||
|  | ||||
| [3;38;2;102;217;239mfunc[0m[38;2;248;248;242m [0m[38;2;166;226;46msum_array[0m[38;2;248;248;242m([0m[3;38;2;253;151;31marr[0m[38;2;248;248;242m: [0m[3;38;2;253;151;31mArray[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114m->[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mint[0m[38;2;248;248;242m:[0m | ||||
| [38;2;248;248;242m	[0m[3;38;2;102;217;239mvar[0m[38;2;248;248;242m [0m[38;2;255;255;255mtotal[0m[38;2;248;248;242m: [0m[3;38;2;102;217;239mint[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;190;132;255m0[0m | ||||
| [38;2;248;248;242m	[0m[38;2;249;38;114mfor[0m[38;2;248;248;242m num [0m[38;2;249;38;114min[0m[38;2;248;248;242m arr:[0m | ||||
| [38;2;248;248;242m		total [0m[38;2;249;38;114m+=[0m[38;2;248;248;242m num[0m | ||||
| [38;2;248;248;242m	[0m[38;2;249;38;114mreturn[0m[38;2;248;248;242m total[0m | ||||
|  | ||||
| [3;38;2;102;217;239mfunc[0m[38;2;248;248;242m [0m[38;2;166;226;46mdescribe_number[0m[38;2;248;248;242m([0m[3;38;2;253;151;31mnum[0m[38;2;248;248;242m: [0m[3;38;2;253;151;31mint[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114m->[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mString[0m[38;2;248;248;242m:[0m | ||||
| [38;2;248;248;242m	[0m[38;2;249;38;114mmatch[0m[38;2;248;248;242m num:[0m | ||||
| [38;2;248;248;242m		[0m[38;2;190;132;255m0[0m[38;2;248;248;242m:[0m | ||||
| [38;2;248;248;242m			[0m[38;2;249;38;114mreturn[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mZero[0m[38;2;230;219;116m"[0m | ||||
| [38;2;248;248;242m		[0m[38;2;190;132;255m1[0m[38;2;248;248;242m, [0m[38;2;190;132;255m2[0m[38;2;248;248;242m, [0m[38;2;190;132;255m3[0m[38;2;248;248;242m:[0m | ||||
| [38;2;248;248;242m			[0m[38;2;249;38;114mreturn[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mSmall number[0m[38;2;230;219;116m"[0m | ||||
| [38;2;248;248;242m		_:[0m | ||||
| [38;2;248;248;242m			[0m[38;2;249;38;114mreturn[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mLarge number[0m[38;2;230;219;116m"[0m | ||||
|  | ||||
| [3;38;2;102;217;239mfunc[0m[38;2;248;248;242m [0m[38;2;166;226;46mlong_description[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114m->[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mString[0m[38;2;248;248;242m:[0m | ||||
| [38;2;248;248;242m	[0m[38;2;249;38;114mreturn[0m[38;2;248;248;242m [0m[38;2;230;219;116m"""[0m[38;2;230;219;116mThis is a test file for GDScript.[0m | ||||
| [38;2;230;219;116mIt covers variables, functions, control structures, loops, signals, inner classes,[0m | ||||
| [38;2;230;219;116mmultiline strings, arrays, and dictionaries.[0m[38;2;230;219;116m"""[0m | ||||
|  | ||||
| [3;38;2;102;217;239mclass[0m[38;2;248;248;242m [0m[38;2;166;226;46mInnerExample[0m[38;2;248;248;242m:[0m | ||||
| [38;2;248;248;242m	[0m[3;38;2;102;217;239mvar[0m[38;2;248;248;242m [0m[38;2;255;255;255minner_value[0m[38;2;248;248;242m: [0m[3;38;2;102;217;239mint[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;190;132;255m99[0m | ||||
| [38;2;248;248;242m	[0m[3;38;2;102;217;239mfunc[0m[38;2;248;248;242m [0m[38;2;166;226;46mshow_value[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114m->[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mvoid[0m[38;2;248;248;242m:[0m | ||||
| [38;2;248;248;242m		[0m[38;2;248;248;242mprint[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mInner value is:[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[38;2;248;248;242m inner_value[0m[38;2;248;248;242m)[0m | ||||
|  | ||||
| [3;38;2;102;217;239mfunc[0m[38;2;248;248;242m [0m[38;2;166;226;46mtest_inner_class[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114m->[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mvoid[0m[38;2;248;248;242m:[0m | ||||
| [38;2;248;248;242m	[0m[3;38;2;102;217;239mvar[0m[38;2;248;248;242m [0m[38;2;255;255;255minner[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m InnerExample.[0m[38;2;248;248;242mnew[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m | ||||
| [38;2;248;248;242m	inner.[0m[38;2;248;248;242mshow_value[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m | ||||
|  | ||||
| [3;38;2;102;217;239mfunc[0m[38;2;248;248;242m [0m[38;2;166;226;46mtrigger_signal[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114m->[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mvoid[0m[38;2;248;248;242m:[0m | ||||
| [38;2;248;248;242m	[0m[38;2;248;248;242memit_signal[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mcustom_signal[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mTestParam[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m | ||||
|  | ||||
| [3;38;2;102;217;239mfunc[0m[38;2;248;248;242m [0m[38;2;166;226;46m_ready[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114m->[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mvoid[0m[38;2;248;248;242m:[0m | ||||
| [38;2;248;248;242m	[0m[38;2;248;248;242msay_hello[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m | ||||
| [38;2;248;248;242m	[0m[3;38;2;102;217;239mvar[0m[38;2;248;248;242m [0m[38;2;255;255;255mresult_add[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;248;248;242madd_numbers[0m[38;2;248;248;242m([0m[38;2;190;132;255m5[0m[38;2;248;248;242m)[0m | ||||
| [38;2;248;248;242m	[0m[38;2;248;248;242mprint[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mAdd result:[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[38;2;248;248;242m result_add[0m[38;2;248;248;242m)[0m | ||||
| [38;2;248;248;242m	[0m[38;2;248;248;242mprint[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mProcess value for -5:[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;248;248;242mprocess_value[0m[38;2;248;248;242m([0m[38;2;249;38;114m-[0m[38;2;190;132;255m5[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m | ||||
| [38;2;248;248;242m	[0m[38;2;248;248;242mprint[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mSum of array [10, 20, 30]:[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;248;248;242msum_array[0m[38;2;248;248;242m([0m[38;2;248;248;242m[[0m[38;2;190;132;255m10[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;190;132;255m20[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;190;132;255m30[0m[38;2;248;248;242m][0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m | ||||
| [38;2;248;248;242m	[0m[38;2;248;248;242mprint[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mDescription for 2:[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;248;248;242mdescribe_number[0m[38;2;248;248;242m([0m[38;2;190;132;255m2[0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m | ||||
| [38;2;248;248;242m	[0m[38;2;248;248;242mprint[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mLong description:\n[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;248;248;242mlong_description[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m)[0m | ||||
| [38;2;248;248;242m	[0m[38;2;248;248;242mtest_inner_class[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m | ||||
| [38;2;248;248;242m	[0m[38;2;248;248;242mtrigger_signal[0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m | ||||
							
								
								
									
										71
									
								
								tests/syntax-tests/source/GDScript/test.gd
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										71
									
								
								tests/syntax-tests/source/GDScript/test.gd
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,71 @@ | ||||
| extends Node | ||||
|  | ||||
| signal custom_signal(param) | ||||
|  | ||||
| const PI = 3.14159 | ||||
|  | ||||
| var untyped_var = "Hello, World!" | ||||
| var typed_int: int = 42 | ||||
| var typed_float: float = 3.14 | ||||
| var typed_string: String = "GDScript Test" | ||||
| var typed_array: Array = [1, 2, 3, 4] | ||||
| var typed_dict: Dictionary = {"key": "value", "number": 100} | ||||
|  | ||||
| onready var label = $Label | ||||
|  | ||||
| func say_hello() -> void: | ||||
| 	print("Hello from GDScript!") | ||||
|  | ||||
| func add_numbers(a: int, b: int = 10) -> int: | ||||
| 	return a + b | ||||
|  | ||||
| func process_value(value: int) -> String: | ||||
| 	if value < 0: | ||||
| 		return "Negative" | ||||
| 	elif value == 0: | ||||
| 		return "Zero" | ||||
| 	else: | ||||
| 		return "Positive" | ||||
|  | ||||
| func sum_array(arr: Array) -> int: | ||||
| 	var total: int = 0 | ||||
| 	for num in arr: | ||||
| 		total += num | ||||
| 	return total | ||||
|  | ||||
| func describe_number(num: int) -> String: | ||||
| 	match num: | ||||
| 		0: | ||||
| 			return "Zero" | ||||
| 		1, 2, 3: | ||||
| 			return "Small number" | ||||
| 		_: | ||||
| 			return "Large number" | ||||
|  | ||||
| func long_description() -> String: | ||||
| 	return """This is a test file for GDScript. | ||||
| It covers variables, functions, control structures, loops, signals, inner classes, | ||||
| multiline strings, arrays, and dictionaries.""" | ||||
|  | ||||
| class InnerExample: | ||||
| 	var inner_value: int = 99 | ||||
| 	func show_value() -> void: | ||||
| 		print("Inner value is:", inner_value) | ||||
|  | ||||
| func test_inner_class() -> void: | ||||
| 	var inner = InnerExample.new() | ||||
| 	inner.show_value() | ||||
|  | ||||
| func trigger_signal() -> void: | ||||
| 	emit_signal("custom_signal", "TestParam") | ||||
|  | ||||
| func _ready() -> void: | ||||
| 	say_hello() | ||||
| 	var result_add = add_numbers(5) | ||||
| 	print("Add result:", result_add) | ||||
| 	print("Process value for -5:", process_value(-5)) | ||||
| 	print("Sum of array [10, 20, 30]:", sum_array([10, 20, 30])) | ||||
| 	print("Description for 2:", describe_number(2)) | ||||
| 	print("Long description:\n", long_description()) | ||||
| 	test_inner_class() | ||||
| 	trigger_signal() | ||||
		Reference in New Issue
	
	Block a user