The Wolfram front end in 2015 and beyond

John Fultz, Wolfram Research, Inc.

Join the Conversation #WolframTechConf

Front end year in review

An infrastructure year for us

• Modernized Unicode and drawing support on Windows

• 64-bit Cocoa port for Mac

• Updated OpenGL and Direct3D implementations

• Not to mention an iOS front end

Front end year in review

But a few interesting features — code captions

Manipulate[Graphics[GeometricTransformation[First[ArrayPlot[CellularAutomaton[30,{{1},0},20]]],{{a,b},{c,d}}],PlotLabel->NumberForm[MatrixForm[{{a,b},{c,d}}],2]],{{a,1},-2,2},{{b,0},-2,2},{{c,0},-2,2},{{d,1},-2,2}]

Front end year in review

But a few interesting features — code captions

Manipulate[Graphics[GeometricTransformation[First[ArrayPlot[CellularAutomaton[30,{{1},0},20]]],{{a,b},{c,d}}],PlotLabel->NumberForm[MatrixForm[{{a,b},{c,d}}],2]],{{a,1},-2,2},{{b,0},-2,2},{{c,0},-2,2},{{d,1},-2,2}]

Languages (in 10.3): simplified and traditional Chinese, French, German, Japanese, Korean, Polish, Portuguese, Russian, Spanish, Ukrainian

Front end year in review

But a few interesting features — code captions

• Easy to turn off or change language

• Available in the help system, too

• And in the cloud and web docs, too

Front end year in review

But a few interesting features — more and better auto-completions

Interpreter

CityData[

SendMail[<|

Front end year in review

But a few interesting features — more and better auto-completions

and coming soon...add your own completions!

RegisterCompletions[myImport,{File,$ExportFormats}]

Front end year in review

But a few interesting features — TextGrid

TextGrid[{{"fruit", "apple", "orange"}, {"vegetable", "lettuce", "squash"}},Dividers->{{2->Blue},{Black,{LightGray},Black}},Background->LightGreen,Frame->True]

...and the year to come

Sneak peek at some coming soon features

File auto-updating

ComboBox

Stack trace

Real time spell-checking

...and the year to come

Sneak peek at some coming soon features — real-time spell checking

Four scorw and seven years ago the our fatthers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal.

...and the year to come

Sneak peek at some coming soon features — real-time spell checking

Hace ocho decadas y siete años, nuestrros padres hicieron nacer en este continente una nueva nación concebida en la libertad y consagrada al principio de que todas las personas son creadas iguales.

...and the year to come

Sneak peek at some coming soon features — combo boxes

InputField["abc",String,MenuList->{"http://www.wolfram.com","http://www.wolframcloud.com"},FieldSize->30]

(and a completion interface coming soon...)

...and the year to come

In-place updates of files

Button["Open notebook",NotebookOpen["C:\\wolfram\\git\\GitLink\\GitLink\\Documentation\\English\\ReferencePages\\Symbols\\GitOpen.nb"]]

<<GitLink`
r=GitOpen["C:\\wolfram\\git\\GitLink"];
GitCheckoutReference[r,"mybranch"];

...and the year to come

Call stacks for messages

f[0]=1;
f[x_]:=If[x < 0,Message[f::underflow],x*f[x-1]]

f[5.]

Some other UI talks...

Today

3:30–4	Mobile CDF Deployment, Rob Raguet-Schofield

4:30–5	Wolfram Cloud App, Nick Zitzmann

Tomorrow

1–1:30	New in 3D graphics, Yuzhu Lu

Thursday

1-2	Typesetting Workshop, Jason Harris

2-3	Principles of Dynamic Interfaces, Lou D’Andria

(and, 9-9:30 I’ll give another talk on git)

Implementation

System`Color
Clear[RegisterCompletions]
RegisterCompletions[sym_,list_]:=
Module[{codes},
	codes = list/.{Directory->8, File->2, Color->4,None->0};
	FE`Evaluate[FEPrivate`AddSpecialArgCompletion[#]]&[ToString[sym]->codes];Null
]

With[{messageHandlers = "Message" /. Internal`Handlers[]},
	(* Add a custom handler *)
	If[!MemberQ[messageHandlers, Internal`MessageStackHandler],
		Internal`AddHandler["Message", Internal`MessageStackHandler]]
]

$ThisNotebook = EvaluationNotebook[];

Internal`MessageStackHandler[Hold[_, False]] := Null;

Internal`MessageStackHandler[Hold[_, _]] := Null /; (EvaluationNotebook[] =!= $ThisNotebook);

Internal`MessageStackHandler[Hold[msg: Message[msgname: MessageName[sym_, tag_], args___], True]] :=
Module[{name, contents, stack},

	stack = Stack[_] /. {vals___, HoldForm[msg], ___} :> {vals, HoldForm[msg]};
	name = Style[Row[{Defer[sym], RawBoxes["::"], RawBoxes[tag]}, None, StripOnInput -> True], "MessageName", FontColor -> RGBColor[0,0,0.67]];
	name = With[{stacklen = Length[stack], stackstr = Compress[stack]},
	Button[name,
		Internal`ShowMessageStack[EvaluationNotebook[], EvaluationBox[], Hold[msg], Uncompress[stackstr]],
		Appearance -> {
			"Default"->None,
			"Hover"->FrontEnd`FileName[{"Ribbons","Common"},"GrayButton-Hover.9.png"],
			"Pressed"->FrontEnd`FileName[{"Ribbons","Common"},"GrayButton-Pressed.9.png"]},
		BaseStyle -> {},
		DefaultBaseStyle -> {},
		Tooltip -> "View the stack" <> " — " <> ToString[Length[stack]] <> " " <> Pluralize["item", stacklen]
	]];

	contents = Which[
		StringQ[msgname], msgname,
		StringQ[MessageName[General, tag]], MessageName[General, tag],
		True, "-- Message text not found --"
	];
	contents = Internal`MessageButtonHandler[contents, Hold[msgname], Hold[msg]];
	(* FIXME: $MessagePrePrint? *)
	contents = StringForm[contents, args];

	CellPrint[ExpressionCell[Row[{name, ": ", contents}, None, StripOnInput -> True], "Message", "MSG"]]
]//Quiet

Internal`ShowMessageStack[nbobj_, boxobj_, Hold[msg: Message[msgname:MessageName[sym_, tag_], args___]], stack_List] :=
Module[{display, stackitemToDisplay},

	stackitemToDisplay[HoldForm[expr_]] := With[{
		str = StringTake[ToString[Hold[expr]/.HoldForm[x_]:>x, InputForm],{6,-2}], len=70,
		boxes = MakeBoxes[InputForm[expr]]},
		If[StringLength[str] < len,
			RawBoxes[boxes],
			FlipView[{Row[{"◀ ▶ ", StringTake[str, len]<>"…"}], Row[{"▶ ◀ ", RawBoxes[boxes]}]}]
		]
	];

	display = Column[Flatten[{
			Item[Row[{"Stack for ", HoldForm[msgname]}], Alignment -> Center, BaseStyle -> "ControlStyle"],
			stackitemToDisplay /@ stack}],
		Dividers -> {Center, Center},
		FrameStyle -> LightGray,
		Spacings -> 1.5,
		ItemSize -> Fit];
	display = Pane[display,
		ImageSize -> Dynamic[CurrentValue[EvaluationNotebook[],{"TaggingRules","MessageStackImageSize"},{600,300}]],
		FrameMargins -> 10,
		AppearanceElements->{"ResizeArea"},
		Scrollbars -> {False, Automatic}];
	display = Panel[display,
		Appearance -> FEPrivate`FrontEndResource["WAExpressions","ControlEqualAssumptionsAppearance"],
		DefaultBaseStyle -> {}];
	
	MathLink`CallFrontEnd[FrontEnd`AttachCell[boxobj, 
		Cell[BoxData[ToBoxes[display]], "Output", (*Deployed -> False,*) FontSize -> Smaller, FontColor -> Black],
		{Automatic,{Left,Bottom}},
		{Left,Top},
		"ClosingActions" -> {"OutsideMouseClick"}
	]]
]//Quiet

CurrentValue[EvaluationNotebook[],{"TaggingRules","MessageStackImageSize"}]=Inherited;

WordData[];