arsd 9.2

Posted 2021-02-22

arsd 9.2 tagged with drag and drop + more, then Java class field access added to arsd.jni (via @property imports), and early write support added to arsd.apng pending next tag.

Core D Development Statistics

In the community

Community announcements

See more at the announce forum.

What Adam is working on

arsd 9.2

This is a big roll-up release with a variety of new things over the last month. Among the highlights:

  • cgi.d's fiber and thread modes now work with delegate handlers, not just static function handlers.
  • dom.d's list of selfClosedElements can now be customized
  • New module arsd.minigui_addons.nanovega provides a nestable minigui widget with a nanovega drawing context.
  • jpeg.d now has file write support.
  • http2.d loads openssl on-demand instead of in the static constructor, so it can be used for non-https without the library if needed. It also loads openssl more reliably on Mac OS systems.
  • jni.d got support for interfacing with more types of java arrays
  • minigui.d's basic ListWidget now works on Windows too and gained a PasswordEdit widget.
  • mysql.d gained some prepared statement helpers
  • nanovega.d now has a NVGWindow class to encapsulate its setup and window creation
    import arsd.nanovega;
    
    void main () {
    	// all the setup is now done in just one line
    	auto window = new NVGWindow(800, 600, "NanoVega Simple Sample");
    
    	// so you can focus on your drawing here
    	window.redrawNVGScene = delegate (nvg) {
    		nvg.beginPath();
    		nvg.moveTo(100, 100);
    		nvg.bezierTo(250, 150, 400, 100, window.width - 50, window.height - 50);
    		nvg.lineTo(100, 100);
    		nvg.fillPaint = nvg.linearGradient(20.5, 30.5, window.width-40, window.height-60,
    		NVGColor("#f70"), NVGColor.green);
    		nvg.strokeColor = NVGColor.white;
    		nvg.strokeWidth = 2;
    		nvg.fill();
    		nvg.stroke();
    	};
    
    	window.eventLoop(0);
    }
  • simpledisplay.d's OperatingSystemFont has some new metric functions
  • terminal.d's line getter can now handle resuming from suspend (linux ctrl+z then fg), more readline style key bindings, new history configuration controls (see: HistoryCommitMode and HistoryRecallFilterMethod), auto-closing brackets, and [arsd,terminal.LineGetter.syntaxHighlightMatch|hooks for inline syntax highlighting] as you type.
    1 import arsd.terminal;
    2 
    3 void main() {
    4 	auto term = Terminal(ConsoleOutputType.linear);
    5 
    6 	term.lineGetter = new class FileLineGetter {
    7 		this() {
    8 			super(&term);
    9 			this.regularForeground = Color.cyan;
    10 		}
    11 		// a string to describe the pairs to auto-complete
    12 		override string enableAutoCloseBrackets() {
    13 			return "()[]{}\"\"";
    14 		}
    15 
    16 		// little implementation of quote detection
    17 		// try typing a quote when you run the program
    18 		override SyntaxHighlightMatch syntaxHighlightMatch(
    19 			in dchar[] line, in size_t cdp, in size_t ccp
    20 		) {
    21 			bool inQuote = false;
    22 			bool escaping = false;
    23 			bool thisOne;
    24 			foreach(idx, dchar ch; line) {
    25 				ch &= ~PRIVATE_BITS_MASK;
    26 				if(ch == '"' && !escaping) {
    27 					if(thisOne) {
    28 						return SyntaxHighlightMatch(
    29 							cast(int) (idx - cdp) + 1,
    30 							Color.red
    31 						);
    32 					}
    33 					inQuote = !inQuote;
    34 				} if(inQuote) {
    35 					if(ch == '\\')
    36 						escaping = true;
    37 					else
    38 						escaping = false;
    39 				}
    40 
    41 				if(idx == cdp) {
    42 					if(inQuote)
    43 						thisOne = true;
    44 					else
    45 						break;
    46 				}
    47 			}
    48 
    49 			if(line.length >= cdp + 5 && line[cdp .. cdp + 5] == " int ") {
    50 				return SyntaxHighlightMatch(
    51 					5,
    52 					Color.green
    53 				);
    54 			}
    55 			return SyntaxHighlightMatch.init;
    56 		}
    57 	};
    58 
    59 	string line = term.getline();
    60 
    61 	while(line !is null) {
    62 		term.writeln(line);
    63 		line = term.getline();
    64 	}
    65 }
  • simpledisplay.d has drag and drop support.
    import arsd.simpledisplay;
    
    void main() {
    	auto window = new SimpleWindow(200, 200, "Text Drop");
    	auto window2 = new SimpleWindow(200, 200, "File Drop");
    	auto drag = new SimpleWindow(150, 150, "Drag");
    
    	drag.setEventHandlers(delegate(MouseEvent ev) {
    		if(ev.type == MouseEventType.buttonPressed) {
    			doDragDrop(drag, draggable("dragged data"));
    		}
    	});
    
    	window.enableDragAndDrop(new TextDropHandler(delegate(in char[] text) {
    		import std.stdio; writeln("Dropped text: ", text);
    	}));
    	window2.enableDragAndDrop(new FilesDropHandler(delegate(in char[][] files) {
    		import std.stdio; writeln("Dropped files: ", files);
    	}));
    
    	window.eventLoop(0);

    The interface is not entirely stable yet but I'm reasonably happy with it now. You can experiment with it in 9.2, but be warned I may break this without a major version bump as I am explicitly disclaiming backward compatibility as of this release. I'll let you know when it is stabilized but you can preview it now as this is release-candidate status.

  • A handful of small bug fixes.

Coming in arsd 9.3

Animated PNG creation is already available in git master:

http://dpldocs.info/experimental-docs/arsd.apng.html#examples

And also Java class fields read/write through JNI:

http://dpldocs.info/experimental-docs/arsd.jni.html

(see the @property member near the bottom of the class in the example at the top)

And of course a lot more as I get to it. I did commit a huge bit to the webview module that allows embedding MS Edge, but it is unlikely to be stabilized for some time.

The official 9.3 tag is not likely to come until the end of March, but we'll see.