def tupleView(ctx, state, node, xs, parser=None):
	def tupleElement(x):
		if x.metadata == PRECEDENCE_TUPLE:
			return paragraph( ctx, python_paragraphStyle, [ text( ctx, punctuation_textStyle, '(' ), x, text( ctx, punctuation_textStyle, ')' ) ] )
		else:
			return x
	if parser is not None:
		xViews = mapViewEval( ctx, xs, None, python25ViewState( parser ) )
	else:
		xViews = mapViewEval( ctx, xs )
	xElements = [ tupleElement( x )   for x in xViews ]
	return nodeEditor( ctx, node,
			   listView( ctx, tuple_listViewLayout, None, None, lambda: text( ctx, punctuation_textStyle, ',' ), xElements ),
			   PRECEDENCE_TUPLE,
			   state )
Example #2
0
def tupleView(state, node, xs, parser=None):
	def tupleWidget(x):
		if x.text.state == PRECEDENCE_TUPLE:
			return ahbox( [ label( '(', punctuationStyle ), x, label( ')', punctuationStyle ) ] )
		else:
			return x
	def tupleText(x):
		if x.state == PRECEDENCE_TUPLE:
			return '(' + x + ')'
		else:
			return x
	if parser is not None:
		xViews = mapViewEval( xs, None, python25ViewState( parser ) )
	else:
		xViews = mapViewEval( xs )
	xWidgets = [ tupleWidget( x )   for x in xViews ]
	xTexts = [ tupleText( x.text )   for x in xViews ]
	return nodeEditor( node,
			   listView( ParagraphListViewLayout( 5.0, 0.0 ), None, None, ',', xWidgets ),
			   UnparsedText( UnparsedText( ', ' ).join( [ x   for x in xTexts ] ), PRECEDENCE_TUPLE ),
			   state )
Example #3
0
	def subscriptTuple(self, state, node, *xs):
		xViews = mapViewEval( xs, None, python25ViewState( Parser.subscriptItem ) )
		return nodeEditor( node,
				   listView( ParagraphListViewLayout( 5.0, 0.0 ), None, None, ',', xViews ),
				   UnparsedText( '( '  +  UnparsedText( ', ' ).join( [ x.text   for x in xViews ] )  +  ' )', PRECEDENCE_TUPLE ),
				   state )
Example #4
0
	def dictLiteral(self, state, node, *xs):
		xViews = mapViewEval( xs, None, python25ViewState( Parser.keyValuePair ) )
		return nodeEditor( node,
				   listView( ParagraphListViewLayout( 10.0, 5.0 ), '{', '}', ',', xViews ),
				   UnparsedText( '{ '  +  UnparsedText( ', ' ).join( [ x.text   for x in xViews ] )  +  ' }', PRECEDENCE_DICTLITERAL ),
				   state )
Example #5
0
	def listLiteral(self, state, node, *xs):
		xViews = mapViewEval( xs )
		return nodeEditor( node,
				   listView( ParagraphListViewLayout( 5.0, 0.0 ), '[', ']', ',', xViews ),
				   UnparsedText( '[ '  +  UnparsedText( ', ' ).join( [ x.text   for x in xViews ] )  +  ' ]', PRECEDENCE_LISTLITERAL ),
				   state )
Example #6
0
	def listTarget(self, state, node, *xs):
		xViews = mapViewEval( xs, None, python25ViewState( Parser.targetItem ) )
		return nodeEditor( node,
				   listView( ParagraphListViewLayout( 5.0, 0.0 ), '[', ']', ',', xViews ),
				   UnparsedText( '[ '  +  UnparsedText( ', ' ).join( [ x.text   for x in xViews ] )  +  ' ]', PRECEDENCE_LISTLITERAL ),
				   state )
Example #7
0
	def python25Module(self, state, node, *content):
		lineViews = mapViewEval( content, None, python25ViewState( Parser.statement, MODE_STATEMENT ) )
		return listView( VerticalListViewLayout( 0.0, 0.0, 0.0 ), None, None, None, lineViews ), ''
Example #8
0
def suiteView(suite):
	lineViews = mapViewEval( suite, None, python25ViewState( Parser.statement, MODE_STATEMENT ) )
	return listView( VerticalListViewLayout( 0.0, 0.0, 0.0 ), None, None, None, lineViews )
	def subscriptTuple(self, ctx, state, node, *xs):
		xViews = mapViewEval( ctx, xs, None, python25ViewState( Parser.subscriptItem ) )
		return nodeEditor( ctx, node,
				   listView( ctx, tuple_listViewLayout, None, None, lambda: text( ctx, punctuation_textStyle, ',' ), xViews ),
				   PRECEDENCE_TUPLE,
				   state )
	def dictLiteral(self, ctx, state, node, *xs):
		xViews = mapViewEval( ctx, xs, None, python25ViewState( Parser.keyValuePair ) )
		return nodeEditor( ctx, node,
				   listView( ctx, dict_listViewLayout, lambda: text( ctx, punctuation_textStyle, '{' ), lambda: text( ctx, punctuation_textStyle, '}' ), lambda: text( ctx, punctuation_textStyle, ',' ), xViews ),
				   PRECEDENCE_DICTLITERAL,
				   state )
	def listLiteral(self, ctx, state, node, *xs):
		xViews = mapViewEval( ctx, xs )
		return nodeEditor( ctx, node,
				   listView( ctx, list_listViewLayout, lambda: text( ctx, punctuation_textStyle, '[' ), lambda: text( ctx, punctuation_textStyle, ']' ), lambda: text( ctx, punctuation_textStyle, ',' ), xViews ),
				   PRECEDENCE_LISTLITERAL,
				   state )
	def listTarget(self, ctx, state, node, *xs):
		xViews = mapViewEval( ctx, xs, None, python25ViewState( Parser.targetItem ) )
		return nodeEditor( ctx, node,
				   listView( ctx, list_listViewLayout, lambda: text( ctx, punctuation_textStyle, '[' ), lambda: text( ctx, punctuation_textStyle, ']' ), lambda: text( ctx, punctuation_textStyle, ',' ), xViews ),
				   None,
				   state )
	def python25Module(self, ctx, state, node, *content):
		lineViews = mapViewEval( ctx, content, None, python25ViewState( Parser.statement, MODE_STATEMENT ) )
		return listView( ctx, module_listViewLayout, None, None, None, lineViews ), ''
def suiteView(ctx, suite):
	lineViews = mapViewEval( ctx, suite, None, python25ViewState( Parser.statement, MODE_STATEMENT ) )
	return listView( ctx, suite_listViewLayout, None, None, None, lineViews )