Exemple #1
0
def embeddedObjectLiteral(ctx, style, valueView, hideFrame):
    embeddedObjectLiteralBorder = style.get(
        PythonEditorStyle.embeddedObjectLiteralBorder)
    embeddedObjectTagLabelStyle = style.get(
        PythonEditorStyle.embeddedObjectTagLabelStyle)
    embeddedObjectTagBorder = style.get(
        PythonEditorStyle.embeddedObjectTagBorder)

    tagLabel = embeddedObjectTagBorder.surround(
        embeddedObjectTagLabelStyle(Label('l')))
    contents = Row([tagLabel.alignVCentre(), valueView.pad(2.0, 2.0)])
    box = embeddedObjectLiteralBorder.surround(contents).padX(1.0, 1.0)

    segment = Segment(box)
    return segment.present(ctx, style)
Exemple #2
0
def unquote(ctx, style, valueView, title, sequentialEditor):
    unquoteBorderStyle = style.get(PythonEditorStyle.unquoteBorderStyle)
    unquoteTitleStyle = style.get(PythonEditorStyle.unquoteTitleStyle)

    titleLabel = unquoteTitleStyle.applyTo(Label(title))

    region = sequentialEditor.region(valueView)

    header = titleLabel.alignHLeft()
    box = unquoteBorderStyle.applyTo(
        Border(Column([header.alignHExpand(),
                       region.pad(3.0, 3.0)]))).pad(1.0, 1.0)

    segment = Segment(box)
    return segment.present(ctx, style)
Exemple #3
0
def externalExpr(ctx, style, exprView, title, deleteButton):
    externalExprBorderStyle = style.get(
        PythonEditorStyle.externalExprBorderStyle)
    externalExprTitleStyle = style.get(
        PythonEditorStyle.externalExprTitleStyle)

    titleLabel = externalExprTitleStyle.applyTo(Label(title))

    header = Row(
        [titleLabel.alignHLeft(),
         deleteButton.alignHRight().alignVCentre()])
    box = externalExprBorderStyle.applyTo(
        Border(Column([header.alignHExpand(),
                       exprView.pad(3.0, 3.0)]))).pad(1.0, 1.0)

    segment = Segment(box)
    return segment.present(ctx, style)
Exemple #4
0
def embeddedObjectStmt(ctx, style, valueView, hideFrame):
    if hideFrame:
        box = valueView
    else:
        embeddedObjectBorder = style.get(
            PythonEditorStyle.embeddedObjectBorder)
        embeddedObjectTagLabelStyle = style.get(
            PythonEditorStyle.embeddedObjectTagLabelStyle)
        embeddedObjectTagBorder = style.get(
            PythonEditorStyle.embeddedObjectTagBorder)

        tagLabel = embeddedObjectTagBorder.surround(
            embeddedObjectTagLabelStyle(Label('Stmt')))
        contents = Column([tagLabel, valueView.pad(2.0, 2.0)])
        box = embeddedObjectBorder.surround(contents).padX(1.0, 1.0)

    segment = Segment(box)
    return segment.present(ctx, style)
def charSet(invert, items):
	items = [ Row( [ Segment( item ) ] )   for item in items ]
	if len( items ) == 1:
		itemsCollection = items[0]
	else:
		width = int( math.ceil( math.sqrt( float( len( items ) ) ) ) )
		itemsCollection = FlowGrid( width, items )
	contents = [ _controlCharStyle( Text( '[' ) ) ]
	if invert:
		contents.append( _invertControlCharStyle( Text( '^' ) ) )
	contents.extend( [ itemsCollection,  _controlCharStyle( Text( ']' ) ) ] )
	return _charSetBorder.surround( Row( contents ) )
Exemple #6
0
def embeddedObjectMacro(ctx, style, valueView, modelView):
    modelView = StyleSheet.style(Primitive.editable(False)).applyTo(modelView)

    embeddedObjectBorderStyle = style.get(
        PythonEditorStyle.embeddedObjectBorderStyle)
    embeddedObjectLineStyle = style.get(
        PythonEditorStyle.embeddedObjectLineStyle)
    embeddedObjectExpansionLabelStyle = style.get(
        PythonEditorStyle.embeddedObjectExpansionLabelStyle)

    hLine = embeddedObjectLineStyle.applyTo(Box(1, 1).alignHExpand()).pad(
        8.0, 2.0).alignHExpand()

    expansionLabel = embeddedObjectExpansionLabelStyle.applyTo(
        Label('Expansion'))

    expander = DropDownExpander(expansionLabel, modelView)

    view = embeddedObjectBorderStyle.applyTo(
        Border(Column([valueView, expander])))

    segment = Segment(view)
    return segment.present(ctx, style)
	def PythonRegEx(self, fragment, inheritedState, model, expr):
		exprView =_editTopLevelNode( expr )
		seg = Segment( exprView )
		e = Paragraph( [ seg ] ).alignHPack().alignVRefY()
		return e
def group(subexp, capturing):
	contents = [ subexp ]   if capturing   else [ _controlCharStyle( Text( '?:' ) ), subexp ]
	b = _groupBorder   if capturing   else _nonCapturingGroupBorder
	return b.surround( Row( [ Segment( Span( [ _controlCharStyle( Text( '(' ) ) ] + contents + [ _controlCharStyle( Text( ')' ) ) ] ) ) ] ) )
def charClass(cls):
	name = _charClasses[cls]
	return _charClassBorder.surround( _charClassStyle( Segment( Row( [ HiddenText( '\\' + cls ), Label( name ) ] ) ) ) )
def _specialChar(char, name):
	return _specialBorder.surround( _specialCharStyle( Segment( Row( [ HiddenText( char ), Label( name ) ] ) ) ) )
Exemple #11
0
def specialFormStatementLine(statement):
    segment = Segment(statement)
    return Paragraph([segment]).alignHPack()
Exemple #12
0
def statementLine(statement):
    segment = Segment(statement)
    newLine = Whitespace('\n')
    return Paragraph([segment, newLine]).alignHPack()