View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide

keep your window size, cursor positions, and keyDownActions of documents when re-opened

Home   How To   Code Pool   Public Library   Theory   Events

[\docKeyDownActions, \docPositions].do { |x|
if( {, };

	var arch, pos, cursor, k, action, saveFunc, loadFunc;
	saveFunc = {|doc| if(doc.path.notNil) {\docPositions).put(doc.path.asSymbol, [doc.bounds, doc.selectionStart]);
			doc.keyDownAction !? {\docKeyDownActions).put(doc.path.asSymbol, doc.keyDownAction.asCompileString)
	loadFunc = {
		var pos, cursor, action;
		#pos, cursor =\docPositions).at(doc.path.asSymbol).asArray;
		if(pos.notNil){{doc.bounds = pos}.defer(0.1)};
		if(cursor.notNil and: { doc.path.endsWith(".sc").not })
		action =\docKeyDownActions).at(doc.path.asSymbol);
		if(action.notNil) {
			doc.keyDownAction = action.interpret;

	doc.onClose = saveFunc;



Link to this Page