1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-17 22:23:10 +03:00

Moving the processing-5503 branch (used for Arduino 0017) into the trunk.

This commit is contained in:
David A. Mellis
2009-08-15 14:48:42 +00:00
886 changed files with 299216 additions and 33965 deletions

10
.classpath Normal file
View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry excluding="processing/app/tools/format/|processing/app/tools/format/src/|processing/app/Trace.java|processing/app/RunnerClassLoader.java" kind="src" path="app/src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/core"/>
<classpathentry kind="lib" path="build/shared/lib/antlr.jar"/>
<classpathentry kind="lib" path="build/shared/lib/registry.jar"/>
<classpathentry kind="lib" path="build/shared/lib/apple.jar"/>
<classpathentry kind="output" path="app/bin"/>
</classpath>

17
.project Normal file
View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>processing-head</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,263 @@
#Thu Jan 10 10:50:38 PST 2008
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
org.eclipse.jdt.core.compiler.compliance=1.4
org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
org.eclipse.jdt.core.compiler.source=1.3
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_assignment=0
org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16
org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0
org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16
org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
org.eclipse.jdt.core.formatter.blank_lines_after_package=1
org.eclipse.jdt.core.formatter.blank_lines_before_field=1
org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0
org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1
org.eclipse.jdt.core.formatter.blank_lines_before_method=1
org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1
org.eclipse.jdt.core.formatter.blank_lines_before_package=0
org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1
org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1
org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line
org.eclipse.jdt.core.formatter.comment.clear_blank_lines=false
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false
org.eclipse.jdt.core.formatter.comment.format_block_comments=true
org.eclipse.jdt.core.formatter.comment.format_comments=true
org.eclipse.jdt.core.formatter.comment.format_header=false
org.eclipse.jdt.core.formatter.comment.format_html=true
org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true
org.eclipse.jdt.core.formatter.comment.format_line_comments=true
org.eclipse.jdt.core.formatter.comment.format_source_code=true
org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true
org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert
org.eclipse.jdt.core.formatter.comment.line_length=80
org.eclipse.jdt.core.formatter.compact_else_if=true
org.eclipse.jdt.core.formatter.continuation_indentation=2
org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2
org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true
org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true
org.eclipse.jdt.core.formatter.indent_empty_lines=false
org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false
org.eclipse.jdt.core.formatter.indentation.size=2
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert
org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false
org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
org.eclipse.jdt.core.formatter.lineSplit=80
org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false
org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false
org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
org.eclipse.jdt.core.formatter.tabulation.char=space
org.eclipse.jdt.core.formatter.tabulation.size=2
org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true

View File

@ -0,0 +1,4 @@
#Thu Jan 10 10:50:38 PST 2008
eclipse.preferences.version=1
formatter_settings_version=11
org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8"?><templates/>

20
app/.classpath Normal file
View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry excluding="processing/app/tools/format/" kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/core"/>
<classpathentry combineaccessrules="false" kind="src" path="/dxf"/>
<classpathentry combineaccessrules="false" kind="src" path="/net"/>
<classpathentry combineaccessrules="false" kind="src" path="/opengl">
<attributes>
<attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="opengl/library"/>
</attributes>
</classpathentry>
<classpathentry combineaccessrules="false" kind="src" path="/pdf"/>
<classpathentry combineaccessrules="false" kind="src" path="/serial"/>
<classpathentry combineaccessrules="false" kind="src" path="/video"/>
<classpathentry kind="lib" path="lib/antlr.jar"/>
<classpathentry kind="lib" path="lib/jna.jar"/>
<classpathentry kind="lib" path="lib/ecj.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

20
app/.classpath_macosx Normal file
View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry excluding="processing/app/tools/format/" kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/core"/>
<classpathentry combineaccessrules="false" kind="src" path="/dxf"/>
<classpathentry combineaccessrules="false" kind="src" path="/net"/>
<classpathentry combineaccessrules="false" kind="src" path="/opengl">
<attributes>
<attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="opengl/library"/>
</attributes>
</classpathentry>
<classpathentry combineaccessrules="false" kind="src" path="/pdf"/>
<classpathentry combineaccessrules="false" kind="src" path="/serial"/>
<classpathentry combineaccessrules="false" kind="src" path="/video"/>
<classpathentry kind="lib" path="lib/antlr.jar"/>
<classpathentry kind="lib" path="lib/jna.jar"/>
<classpathentry kind="lib" path="lib/ecj.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

21
app/.classpath_vista Executable file
View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry excluding="processing/app/tools/format/|processing/app/macosx/" kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/core"/>
<classpathentry combineaccessrules="false" kind="src" path="/dxf"/>
<classpathentry combineaccessrules="false" kind="src" path="/net"/>
<classpathentry combineaccessrules="false" kind="src" path="/opengl">
<attributes>
<attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="opengl/library"/>
</attributes>
</classpathentry>
<classpathentry combineaccessrules="false" kind="src" path="/pdf"/>
<classpathentry combineaccessrules="false" kind="src" path="/serial"/>
<classpathentry combineaccessrules="false" kind="src" path="/video"/>
<classpathentry kind="lib" path="lib/antlr.jar"/>
<classpathentry kind="lib" path="lib/jna.jar"/>
<classpathentry kind="lib" path="lib/ecj.jar"/>
<classpathentry kind="lib" path="C:/Users/fry/processing/build/windows/work/java/lib/tools.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

17
app/.project Normal file
View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>processing</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,320 @@
#Wed Jun 04 15:47:46 EDT 2008
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
org.eclipse.jdt.core.compiler.problem.deprecation=warning
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
org.eclipse.jdt.core.compiler.problem.finalParameterBound=ignore
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
org.eclipse.jdt.core.compiler.problem.nullReference=ignore
org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=ignore
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
org.eclipse.jdt.core.compiler.problem.unusedImport=warning
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
org.eclipse.jdt.core.compiler.source=1.5
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=18
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_assignment=0
org.eclipse.jdt.core.formatter.alignment_for_binary_expression=18
org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=82
org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0
org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=18
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=18
org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16
org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
org.eclipse.jdt.core.formatter.blank_lines_after_package=1
org.eclipse.jdt.core.formatter.blank_lines_before_field=1
org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0
org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1
org.eclipse.jdt.core.formatter.blank_lines_before_method=1
org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1
org.eclipse.jdt.core.formatter.blank_lines_before_package=0
org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1
org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1
org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false
org.eclipse.jdt.core.formatter.comment.format_block_comments=true
org.eclipse.jdt.core.formatter.comment.format_header=false
org.eclipse.jdt.core.formatter.comment.format_html=true
org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true
org.eclipse.jdt.core.formatter.comment.format_line_comments=true
org.eclipse.jdt.core.formatter.comment.format_source_code=true
org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true
org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert
org.eclipse.jdt.core.formatter.comment.line_length=80
org.eclipse.jdt.core.formatter.compact_else_if=true
org.eclipse.jdt.core.formatter.continuation_indentation=2
org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2
org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true
org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true
org.eclipse.jdt.core.formatter.indent_empty_lines=false
org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false
org.eclipse.jdt.core.formatter.indentation.size=2
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert
org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false
org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
org.eclipse.jdt.core.formatter.lineSplit=80
org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false
org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false
org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
org.eclipse.jdt.core.formatter.tabulation.char=space
org.eclipse.jdt.core.formatter.tabulation.size=2
org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true

View File

@ -0,0 +1,4 @@
#Tue Jun 03 17:00:03 EDT 2008
eclipse.preferences.version=1
formatter_profile=_two spaces no tabs
formatter_settings_version=11

View File

@ -1,149 +0,0 @@
/*
Part of the Arduino project - http://arduino.berlios.de
This class reads from an input stream
and flushes out everything to the System.out
It can report interrupts back to the parent process
@author DojoDave
@www http://www.0j0.org
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// TODO migrate codebase to arduino.app
package processing.app;
import java.io.*;
class ArduinoMessageSiphon extends Thread
{
/** Stream to read from */
InputStream is;
/** Process' parent in execution */
Thread parent;
/** Output message from System.error */
public String theMsg ="";
/** Result value to be sent back */
public int result = -1;
/** Count errors and warnings to be sent back */
public int totalErrors = 0;
/** Debug Errors and Warnings */
public boolean debugWarning = false;
public boolean debugError = false;
public boolean logAllOutput = false;
/**
* Creates the stream to flush
* @param theIS is the input stream we will monitor
* process is the parent process that called this
*/
public ArduinoMessageSiphon(InputStream theIS, Thread process)
{
// Assign to member variables
is = theIS;
parent = process;
}
/**
* Creates the stream to flush
* @param theIS is the input stream we will monitor
* process is the parent process that called this
* warnings will debug warnings when calling commands
* errors will debug errors when calling commands
*/
/**
* The errors it will report are in the ranges
* 49 - 0 for the programmer's errors
* 99 - 50 for the compiler's errors
*/
public ArduinoMessageSiphon(InputStream theIS, Thread process, boolean warnings, boolean errors)
{
// Assign to member variables
is = theIS;
parent = process;
debugWarning = warnings;
debugError = errors;
}
/**
* The errors it will report are in the ranges
* 49 - 0 for the programmer's errors
* 99 - 50 for the compiler's errors
*/
public ArduinoMessageSiphon(InputStream theIS, Thread process, boolean outlog)
{
// Assign to member variables
is = theIS;
parent = process;
logAllOutput = outlog;
}
/** Performs system call specific code */
public void run()
{
BufferedReader br = new BufferedReader(new InputStreamReader(is));
try {
String theLine;
while ((theLine = br.readLine()) != null) {
if (logAllOutput) {
theMsg += theLine + "\r\n";
//System.out.println(theMsg);
}
if ((theLine.indexOf("warning:") != -1) && (theLine.indexOf("prog.c:") != -1) && (debugWarning)) {
theMsg += theLine + "\r\n";
totalErrors++;
}
if ((theLine.indexOf("error:") != -1) && (theLine.indexOf("prog.c:") != -1) && (debugError)) {
result = 97;
theMsg += theLine + "\r\n";
totalErrors++;
}
if (theLine.indexOf("Errors: none") != -1) {
result = 0;
}
if (theLine.indexOf("bytes transferred") != -1) {
result = 0;
}
if (theLine.toLowerCase().indexOf("not responding") != -1) {
result = 49;
}
}
br.close();
// waits 20 secs until being killed by the
// parent process or just dies, no zombies wanted!!
try {
Thread.currentThread().sleep(20000);
} catch (InterruptedException ie) {
}
} catch (Exception err) {
err.printStackTrace();
result = 96;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,153 +0,0 @@
/*
Part of the Arduino project - http://arduino.berlios.de
This class creates a compilation thread
this is needed for detecting time-outs
in system calls. It may happen in
windows whenever there is a syntax error
that the compilation may hang the IDE
@author DojoDave
@www http://www.0j0.org
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// TODO migrate codebase to arduino.app
package processing.app;
import java.io.*;
class Command extends Thread
{
/** Command to execute on command line */
String command;
/** Process in execution */
Process process;
/** Output message from System.out */
public String outMsg ="";
/** Error message from System.error */
public String errorMsg ="";
/** Result value to be sent back */
public int outResult = -1;
public int errorResult = -1;
/** Total errors and warnings to be sent back */
public int totalErrors = 0;
/** Waiting value */
public int waitResult = -1;
/** Debug Errors and Warnings */
public boolean debugWarning = false;
public boolean debugError = false;
public boolean logAllOutput = false;
/**
* Creates the compiler object with the
* gnumake line to call
* @param command name of the command line to call
*/
public Command (String co)
{
// Assign to member variable
command = co;
}
/**
* Creates the compiler object with the
* gnumake line to call
* @param command name of the command line to call
* outlog will debug warnings when calling commands
*/
public Command (String co, boolean outlog)
{
// Assign to member variable
command = co;
logAllOutput = outlog;
}
/**
* Creates the compiler object with the
* gnumake line to call
* @param command name of the command line to call
* warnings will debug warnings when calling commands
* errors will debug errors when calling commands
*/
public Command (String co, boolean warnings, boolean errors)
{
// Assign to member variable
command = co;
debugWarning = warnings;
debugError = errors;
}
/** Performs system call specific code */
public void run()
{
try {
process = Runtime.getRuntime().exec(command);
ArduinoMessageSiphon input;
ArduinoMessageSiphon error;
if (logAllOutput) {
input = new ArduinoMessageSiphon(process.getInputStream(), this, logAllOutput);
error = new ArduinoMessageSiphon(process.getErrorStream(), this, logAllOutput);
} else {
input = new ArduinoMessageSiphon(process.getInputStream(), this, debugWarning, debugError);
error = new ArduinoMessageSiphon(process.getErrorStream(), this, debugWarning, debugError);
}
input.start();
error.start();
// wait for the process to finish. if interrupted
// before waitFor returns, continue waiting
//
boolean compiling = true;
while (compiling) {
try {
waitResult = process.waitFor();
outResult = input.result;
errorResult = error.result;
compiling = false;
} catch (InterruptedException ignored) { }
}
try {
waitResult = process.exitValue();
} catch (IllegalThreadStateException ignored) { }
// trace the error and outout
outMsg = input.theMsg;
errorMsg = error.theMsg;
totalErrors = error.totalErrors;
// waits 20 secs until being killed by the
// parent process or just dies, no zombies wanted!!
try {
Thread.currentThread().sleep(20000);
} catch (InterruptedException ie) {
}
} catch (IOException ioe) {
outResult = 99;
}
}
}

View File

@ -1,600 +0,0 @@
/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
Compiler - default compiler class that connects to avr-gcc
Part of the Arduino project - http://www.arduino.cc/
Modified by David A. Mellis
Copyright (c) 2004-05 Hernando Barragan
Processing version
Copyright (c) 2004-05 Ben Fry and Casey Reas
Copyright (c) 2001-04 Massachusetts Institute of Technology
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
$Id$
*/
package processing.app;
import java.io.*;
import java.util.*;
import java.util.zip.*;
import javax.swing.*;
public class Compiler implements MessageConsumer {
static final String BUGS_URL =
"https://developer.berlios.de/bugs/?group_id=3590";
static final String SUPER_BADNESS =
"Compiler error, please submit this code to " + BUGS_URL;
Sketch sketch;
String buildPath;
//String buildPath;
//String className;
//File includeFolder;
RunnerException exception;
//Editor editor;
/*
public Compiler(String buildPath, String className,
File includeFolder, Editor editor) {
this.buildPath = buildPath;
this.includeFolder = includeFolder;
this.className = className;
this.editor = editor;
}
public boolean compile(PrintStream leechErr) {
*/
public Compiler() { } // consider this a warning, you werkin soon.
public boolean compile(Sketch sketch, String buildPath, Target target)
throws RunnerException {
this.sketch = sketch;
this.buildPath = buildPath;
// the pms object isn't used for anything but storage
MessageStream pms = new MessageStream(this);
String userdir = System.getProperty("user.dir") + File.separator;
// LibraryManager libraryManager;
//
// try {
// libraryManager = new LibraryManager();
// } catch (IOException e) {
// throw new RunnerException(e.getMessage());
// }
String avrBasePath;
if(Base.isMacOS()) {
avrBasePath = new String("hardware/tools/avr/bin/");
}
else if(Base.isLinux()) {
avrBasePath = new String("");
}
else {
avrBasePath = new String(userdir + "hardware/tools/avr/bin/");
}
List includePaths = new ArrayList();
includePaths.add(target.getPath());
// use lib directories as include paths
for (int i = 0; i < sketch.importedLibraries.size(); i++) {
includePaths.add(
((Library) sketch.importedLibraries.get(i)).getFolder().getPath());
}
List baseCommandLinker = new ArrayList(Arrays.asList(new String[] {
avrBasePath + "avr-gcc",
"-Os",
"-Wl,--gc-sections",
"-mmcu=" + Preferences.get("boards." + Preferences.get("board") + ".build.mcu"),
"-o",
buildPath + File.separator + sketch.name + ".elf"
}));
String runtimeLibraryName = buildPath + File.separator + "core.a";
List baseCommandAR = new ArrayList(Arrays.asList(new String[] {
avrBasePath + "avr-ar",
"rcs",
runtimeLibraryName
}));
// use lib object files
for (Iterator i = sketch.importedLibraries.iterator(); i.hasNext(); ) {
Library library = (Library) i.next();
File[] objectFiles = library.getObjectFiles();
for (int j = 0; j < objectFiles.length; j++)
baseCommandLinker.add(objectFiles[j].getPath());
}
List baseCommandObjcopy = new ArrayList(Arrays.asList(new String[] {
avrBasePath + "avr-objcopy",
"-O",
"-R",
}));
// make list of code files that need to be compiled and the object files
// that they will be compiled to (includes code from the sketch and the
// library for the target platform)
List sourceNames = new ArrayList();
List sourceNamesCPP = new ArrayList();
List objectNames = new ArrayList();
List objectNamesCPP = new ArrayList();
List targetObjectNames = new ArrayList();
List sketchObjectNames = new ArrayList();
for (int i = 0; i < sketch.codeCount; i++) {
if (sketch.code[i].preprocName != null) {
if (sketch.code[i].preprocName.endsWith(".c")) {
sourceNames.add(buildPath + File.separator + sketch.code[i].preprocName);
objectNames.add(buildPath + File.separator + sketch.code[i].preprocName + ".o");
sketchObjectNames.add(buildPath + File.separator + sketch.code[i].preprocName + ".o");
} else if (sketch.code[i].preprocName.endsWith(".cpp")) {
sourceNamesCPP.add(buildPath + File.separator + sketch.code[i].preprocName);
objectNamesCPP.add(buildPath + File.separator + sketch.code[i].preprocName + ".o");
sketchObjectNames.add(buildPath + File.separator + sketch.code[i].preprocName + ".o");
}
}
}
for (Iterator iter = target.getSourceFilenames().iterator(); iter.hasNext(); ) {
String filename = (String) iter.next();
if (filename != null) {
targetObjectNames.add(buildPath + File.separator + filename + ".o");
if (filename.endsWith(".c")) {
sourceNames.add(target.getPath() + File.separator + filename);
objectNames.add(buildPath + File.separator + filename + ".o");
} else if (filename.endsWith(".cpp")) {
sourceNamesCPP.add(target.getPath() + File.separator + filename);
objectNamesCPP.add(buildPath + File.separator + filename + ".o");
}
}
}
baseCommandLinker.addAll(sketchObjectNames);
//baseCommandLinker.addAll(targetObjectNames);
baseCommandLinker.add(runtimeLibraryName);
baseCommandLinker.add("-L" + buildPath);
baseCommandLinker.add("-lm");
firstErrorFound = false; // haven't found any errors yet
secondErrorFound = false;
int result = 0; // pre-initialized to quiet a bogus warning from jikes
try {
// execute the compiler, and create threads to deal
// with the input and error streams
//
Process process;
boolean compiling = true;
for(int i = 0; i < sourceNames.size(); i++) {
if (execAsynchronously(getCommandCompilerC(avrBasePath, includePaths,
(String) sourceNames.get(i), (String) objectNames.get(i))) != 0)
return false;
}
for(int i = 0; i < sourceNamesCPP.size(); i++) {
if (execAsynchronously(getCommandCompilerCPP(avrBasePath, includePaths,
(String) sourceNamesCPP.get(i), (String) objectNamesCPP.get(i))) != 0)
return false;
}
for(int i = 0; i < targetObjectNames.size(); i++) {
List commandAR = new ArrayList(baseCommandAR);
commandAR.add(targetObjectNames.get(i));
if (execAsynchronously(commandAR) != 0)
return false;
}
if (execAsynchronously(baseCommandLinker) != 0)
return false;
List commandObjcopy;
// Extract EEPROM data (from EEMEM directive) to .eep file.
commandObjcopy = new ArrayList(baseCommandObjcopy);
commandObjcopy.add(2, "ihex");
commandObjcopy.set(3, "-j");
commandObjcopy.add(".eeprom");
commandObjcopy.add("--set-section-flags=.eeprom=alloc,load");
commandObjcopy.add("--no-change-warnings");
commandObjcopy.add("--change-section-lma");
commandObjcopy.add(".eeprom=0");
commandObjcopy.add(buildPath + File.separator + sketch.name + ".elf");
commandObjcopy.add(buildPath + File.separator + sketch.name + ".eep");
if (execAsynchronously(commandObjcopy) != 0)
return false;
commandObjcopy = new ArrayList(baseCommandObjcopy);
commandObjcopy.add(2, "ihex");
commandObjcopy.add(".eeprom"); // remove eeprom data
commandObjcopy.add(buildPath + File.separator + sketch.name + ".elf");
commandObjcopy.add(buildPath + File.separator + sketch.name + ".hex");
if (execAsynchronously(commandObjcopy) != 0)
return false;
} catch (Exception e) {
String msg = e.getMessage();
if ((msg != null) && (msg.indexOf("avr-gcc: not found") != -1)) {
//System.err.println("jikes is missing");
Base.showWarning("Compiler error",
"Could not find the compiler.\n" +
"avr-gcc is missing from your PATH.", null);
return false;
} else {
e.printStackTrace();
result = -1;
}
}
// an error was queued up by message(), barf this back to build()
// which will barf it back to Editor. if you're having trouble
// discerning the imagery, consider how cows regurgitate their food
// to digest it, and the fact that they have five stomaches.
//
//System.out.println("throwing up " + exception);
if (exception != null) throw exception;
// if the result isn't a known, expected value it means that something
// is fairly wrong, one possibility is that jikes has crashed.
//
if (result != 0 && result != 1 ) {
//exception = new RunnerException(SUPER_BADNESS);
//editor.error(exception); // this will instead be thrown
Base.openURL(BUGS_URL);
throw new RunnerException(SUPER_BADNESS);
}
// success would mean that 'result' is set to zero
return (result == 0); // ? true : false;
}
public int execAsynchronously(List commandList)
throws RunnerException, IOException {
String[] command = new String[commandList.size()];
commandList.toArray(command);
int result = 0;
if (Preferences.getBoolean("build.verbose")) {
for(int j = 0; j < command.length; j++) {
System.out.print(command[j] + " ");
}
System.out.println();
}
Process process = Runtime.getRuntime().exec(command);
new MessageSiphon(process.getInputStream(), this);
new MessageSiphon(process.getErrorStream(), this);
// wait for the process to finish. if interrupted
// before waitFor returns, continue waiting
boolean compiling = true;
while (compiling) {
try {
result = process.waitFor();
//System.out.println("result is " + result);
compiling = false;
} catch (InterruptedException ignored) { }
}
if (exception != null) {
exception.hideStackTrace = true;
throw exception;
}
return result;
}
boolean firstErrorFound;
boolean secondErrorFound;
/**
* Part of the MessageConsumer interface, this is called
* whenever a piece (usually a line) of error message is spewed
* out from the compiler. The errors are parsed for their contents
* and line number, which is then reported back to Editor.
*/
public void message(String s) {
// This receives messages as full lines, so a newline needs
// to be added as they're printed to the console.
//System.err.print(s);
// ignore cautions
if (s.indexOf("warning") != -1) return;
// jikes always uses a forward slash character as its separator,
// so replace any platform-specific separator characters before
// attemping to compare
//
//String buildPathSubst = buildPath.replace(File.separatorChar, '/') + "/";
String buildPathSubst = buildPath.replace(File.separatorChar,File.separatorChar) + File.separatorChar;
String partialTempPath = null;
int partialStartIndex = -1; //s.indexOf(partialTempPath);
int fileIndex = -1; // use this to build a better exception
// iterate through the project files to see who's causing the trouble
for (int i = 0; i < sketch.codeCount; i++) {
if (sketch.code[i].preprocName == null) continue;
partialTempPath = buildPathSubst + sketch.code[i].preprocName;
partialStartIndex = s.indexOf(partialTempPath);
if (partialStartIndex != -1) {
fileIndex = i;
//System.out.println("fileIndex is " + fileIndex);
break;
}
}
//+ className + ".java";
// if the partial temp path appears in the error message...
//
//int partialStartIndex = s.indexOf(partialTempPath);
if (partialStartIndex != -1) {
// skip past the path and parse the int after the first colon
//
String s1 = s.substring(partialStartIndex +
partialTempPath.length() + 1);
//System.out.println(s1);
int colon = s1.indexOf(':');
if (s1.indexOf("In function") != -1 || colon == -1) {
System.err.print(s1);
//firstErrorFound = true;
return;
}
int lineNumber;
try {
lineNumber = Integer.parseInt(s1.substring(0, colon));
} catch (NumberFormatException e) {
System.err.print(s1);
return;
}
// the "1" corresponds to the amount of lines written to the main code
// file by PdePreprocessor's writeHeader() routine before prototypes
if (fileIndex == 0)
lineNumber -= 1;
//System.out.println("pde / line number: " + lineNumber);
if (fileIndex == 0) { // main class, figure out which tab
for (int i = 1; i < sketch.codeCount; i++) {
if (sketch.code[i].flavor == Sketch.PDE) {
//System.out.println("preprocOffset "+ sketch.code[i].preprocOffset);
if (sketch.code[i].preprocOffset < lineNumber) {
fileIndex = i;
//System.out.println("i'm thinkin file " + i);
}
}
}
if (fileIndex != 0) { // if found another culprit
lineNumber -= sketch.code[fileIndex].preprocOffset;
//System.out.println("i'm sayin line " + lineNumber);
}
}
//String s2 = s1.substring(colon + 2);
int err = s1.indexOf(":");
if (err != -1) {
// if the first error has already been found, then this must be
// (at least) the second error found
if (firstErrorFound) {
secondErrorFound = true;
return;
}
// if executing at this point, this is *at least* the first error
firstErrorFound = true;
err += ":".length();
String description = s1.substring(err);
description = description.trim();
System.err.print(description);
/* String hasLoop = "The method \"void loop();\" with default access";
if (description.indexOf(hasLoop) != -1) {
description =
"Rename loop() to draw() in Processing 0070 and higher";
}
*/
/* String constructorProblem =
"No applicable overload was found for a constructor of type";
if (description.indexOf(constructorProblem) != -1) {
//"simong.particles.ParticleSystem". Perhaps you wanted the overloaded version "ParticleSystem();" instead?
int nextSentence = description.indexOf("\".") + 3;
description = description.substring(nextSentence);
}
*/
/* String overloadProblem = "No applicable overload";
if (description.indexOf(overloadProblem) != -1) {
int nextSentence = description.indexOf("\".") + 3;
description = description.substring(nextSentence);
}
*/
// c:/fry/processing/build/windows/work/lib/build/Temporary_6858_2476.java:1:34:1:41: Semantic Error: You need to modify your classpath, sourcepath, bootclasspath, and/or extdirs setup. Package "poo/shoe" could not be found in:
/* String classpathProblem = "You need to modify your classpath";
if (description.indexOf(classpathProblem) != -1) {
if (description.indexOf("quicktime/std") != -1) {
// special case for the quicktime libraries
description =
"To run sketches that use the Processing video library, " +
"you must first install QuickTime for Java.";
} else {
int nextSentence = description.indexOf(". Package") + 2;
description =
description.substring(nextSentence, description.indexOf(':')) +
" the code folder or in any libraries.";
}
}
*/
//System.out.println("description = " + description);
//System.out.println("creating exception " + exception);
exception = new RunnerException(description, fileIndex, lineNumber-1, -1);
// NOTE!! major change here, this exception will be queued
// here to be thrown by the compile() function
//editor.error(exception);
} else {
System.err.println("i suck: " + s);
}
} else {
// this isn't the start of an error line, so don't attempt to parse
// a line number out of it.
// if the second error hasn't been discovered yet, these lines
// are probably associated with the first error message,
// which is already in the status bar, and are likely to be
// of interest to the user, so spit them to the console.
//
if (!secondErrorFound) {
System.err.println(s);
}
}
}
static private List getCommandCompilerC(String avrBasePath, List includePaths,
String sourceName, String objectName) {
List baseCommandCompiler = new ArrayList(Arrays.asList(new String[] {
avrBasePath + "avr-gcc",
"-c", // compile, don't link
"-g", // include debugging info (so errors include line numbers)
"-Os", // optimize for size
"-w", // surpress all warnings
"-ffunction-sections", // place each function in its own section
"-fdata-sections",
"-mmcu=" + Preferences.get("boards." + Preferences.get("board") + ".build.mcu"),
"-DF_CPU=" + Preferences.get("boards." + Preferences.get("board") + ".build.f_cpu"),
}));
for (int i = 0; i < includePaths.size(); i++) {
baseCommandCompiler.add("-I" + (String) includePaths.get(i));
}
baseCommandCompiler.add(sourceName);
baseCommandCompiler.add("-o"+ objectName);
return baseCommandCompiler;
}
static private List getCommandCompilerCPP(String avrBasePath,
List includePaths, String sourceName, String objectName) {
List baseCommandCompilerCPP = new ArrayList(Arrays.asList(new String[] {
avrBasePath + "avr-g++",
"-c", // compile, don't link
"-g", // include debugging info (so errors include line numbers)
"-Os", // optimize for size
"-w", // surpress all warnings
"-fno-exceptions",
"-ffunction-sections", // place each function in its own section
"-fdata-sections",
"-mmcu=" + Preferences.get("boards." + Preferences.get("board") + ".build.mcu"),
"-DF_CPU=" + Preferences.get("boards." + Preferences.get("board") + ".build.f_cpu"),
}));
for (int i = 0; i < includePaths.size(); i++) {
baseCommandCompilerCPP.add("-I" + (String) includePaths.get(i));
}
baseCommandCompilerCPP.add(sourceName);
baseCommandCompilerCPP.add("-o"+ objectName);
return baseCommandCompilerCPP;
}
static String bootClassPath;
static public String calcBootClassPath() {
if (bootClassPath == null) {
String additional = "";
if (Base.isMacOS()) {
additional =
contentsToClassPath(new File("/System/Library/Java/Extensions/"));
}
bootClassPath = System.getProperty("sun.boot.class.path") + additional;
}
return bootClassPath;
}
///
/**
* Return the path for a folder, with appended paths to
* any .jar or .zip files inside that folder.
* This will prepend a colon (or whatever the path separator is)
* so that it can be directly appended to another path string.
*
* This will always add the root folder as well, and doesn't bother
* checking to see if there are any .class files in the folder or
* within a subfolder.
*/
static public String contentsToClassPath(File folder) {
if (folder == null) return "";
StringBuffer abuffer = new StringBuffer();
String sep = System.getProperty("path.separator");
try {
// add the folder itself in case any unzipped files
String path = folder.getCanonicalPath();
abuffer.append(sep);
abuffer.append(path);
if (!path.endsWith(File.separator)) {
path += File.separator;
}
//System.out.println("path is " + path);
String list[] = folder.list();
for (int i = 0; i < list.length; i++) {
if (list[i].toLowerCase().endsWith(".o") ||
list[i].toLowerCase().endsWith(".a")) {
abuffer.append(sep);
abuffer.append(path);
abuffer.append(list[i]);
}
}
} catch (IOException e) {
e.printStackTrace(); // this would be odd
}
//System.out.println("included path is " + abuffer.toString());
//packageListFromClassPath(abuffer.toString()); // WHY?
return abuffer.toString();
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,536 +0,0 @@
/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
Part of the Processing project - http://processing.org
Copyright (c) 2004-05 Ben Fry and Casey Reas
Copyright (c) 2001-04 Massachusetts Institute of Technology
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
$Id$
*/
package processing.app;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/**
* Panel just below the editing area that contains status messages.
*/
public class EditorStatus extends JPanel implements ActionListener {
static Color bgcolor[];
static Color fgcolor[];
static final int NOTICE = 0;
static final int ERR = 1;
static final int PROMPT = 2;
static final int EDIT = 3;
static final int SERIAL = 4;
static final int YES = 1;
static final int NO = 2;
static final int CANCEL = 3;
static final int OK = 4;
static final int SEND = 5;
static final String NO_MESSAGE = "";
Editor editor;
int mode;
String message;
Font font;
FontMetrics metrics;
int ascent;
Image offscreen;
int sizeW, sizeH;
int imageW, imageH;
JButton yesButton;
JButton noButton;
JButton cancelButton;
JButton okButton;
JButton sendButton;
JTextField editField;
JTextField serialField;
JComboBox serialRates;
//Thread promptThread;
int response;
public EditorStatus(Editor editor) {
this.editor = editor;
empty();
if (bgcolor == null) {
bgcolor = new Color[5];
// Arduino 0003 switched to a blue color scheme to visually distinguish
// itself from Processing. Because the image files for certain interface
// elements (e.g. buttons and tabs) are distributed with the application
// while the preference file that specifies the IDE colors is stored in
// the user's home directory and shared across all versions of Arduino,
// we need to hardcode certain colors here to match the images.
// Otherwise, users who used different multiple versions of the software
// would sometimes see colors that didn't match the interface elements.
// This is a hack and prevents users from customizing the IDE colors,
// however, it obviates the need to provide for version-specific
// preferences.
//bgcolor[0] = Preferences.getColor("status.notice.bgcolor");
bgcolor[0] = new Color(0x54, 0x91, 0x9e);
bgcolor[1] = Preferences.getColor("status.error.bgcolor");
bgcolor[2] = Preferences.getColor("status.prompt.bgcolor");
bgcolor[3] = Preferences.getColor("status.prompt.bgcolor");
bgcolor[4] = new Color(0x54, 0x91, 0x9e);
fgcolor = new Color[5];
fgcolor[0] = Preferences.getColor("status.notice.fgcolor");
fgcolor[1] = Preferences.getColor("status.error.fgcolor");
fgcolor[2] = Preferences.getColor("status.prompt.fgcolor");
fgcolor[3] = Preferences.getColor("status.prompt.fgcolor");
fgcolor[4] = Preferences.getColor("status.notice.fgcolor");
}
}
public void empty() {
mode = NOTICE;
message = NO_MESSAGE;
//update();
repaint();
}
public void notice(String message) {
mode = NOTICE;
this.message = message;
//update();
repaint();
}
public void unnotice(String unmessage) {
if (message.equals(unmessage)) empty();
}
public void error(String message) {
mode = ERR;
this.message = message;
repaint();
}
public void prompt(String message) {
mode = PROMPT;
this.message = message;
response = 0;
yesButton.setVisible(true);
noButton.setVisible(true);
cancelButton.setVisible(true);
yesButton.requestFocus();
repaint();
}
// prompt has been handled, re-hide the buttons
public void unprompt() {
yesButton.setVisible(false);
noButton.setVisible(false);
cancelButton.setVisible(false);
empty();
}
public void edit(String message, String dflt) {
mode = EDIT;
this.message = message;
response = 0;
okButton.setVisible(true);
cancelButton.setVisible(true);
editField.setVisible(true);
editField.setText(dflt);
editField.selectAll();
editField.requestFocus();
repaint();
}
public void unedit() {
okButton.setVisible(false);
cancelButton.setVisible(false);
editField.setVisible(false);
empty();
}
public void serial()
{
mode = SERIAL;
this.message = NO_MESSAGE;
sendButton.setVisible(true);
serialRates.setVisible(true);
serialField.setVisible(true);
serialField.setText("");
serialField.requestFocus();
repaint();
}
public void unserial()
{
sendButton.setVisible(false);
serialField.setVisible(false);
serialRates.setVisible(false);
empty();
}
/*
public void update() {
Graphics g = this.getGraphics();
try {
setBackground(bgcolor[mode]);
} catch (NullPointerException e) { } // if not ready yet
if (g != null) paint(g);
}
public void update(Graphics g) {
paint(g);
}
*/
public void paintComponent(Graphics screen) {
//if (screen == null) return;
if (yesButton == null) setup();
//System.out.println("status.paintComponent");
Dimension size = getSize();
if ((size.width != sizeW) || (size.height != sizeH)) {
// component has been resized
if ((size.width > imageW) || (size.height > imageH)) {
// nix the image and recreate, it's too small
offscreen = null;
} else {
// who cares, just resize
sizeW = size.width;
sizeH = size.height;
setButtonBounds();
}
}
if (offscreen == null) {
sizeW = size.width;
sizeH = size.height;
setButtonBounds();
imageW = sizeW;
imageH = sizeH;
offscreen = createImage(imageW, imageH);
}
Graphics g = offscreen.getGraphics();
if (font == null) {
font = Preferences.getFont("status.font");
//new Font("SansSerif", Font.PLAIN, 12));
g.setFont(font);
metrics = g.getFontMetrics();
ascent = metrics.getAscent();
}
//setBackground(bgcolor[mode]); // does nothing
g.setColor(bgcolor[mode]);
g.fillRect(0, 0, imageW, imageH);
g.setColor(fgcolor[mode]);
g.setFont(font); // needs to be set each time on osx
g.drawString(message, Preferences.GUI_SMALL, (sizeH + ascent) / 2);
screen.drawImage(offscreen, 0, 0, null);
}
protected void setup() {
if (yesButton == null) {
yesButton = new JButton(Preferences.PROMPT_YES);
noButton = new JButton(Preferences.PROMPT_NO);
cancelButton = new JButton(Preferences.PROMPT_CANCEL);
okButton = new JButton(Preferences.PROMPT_OK);
sendButton = new JButton(Preferences.PROMPT_SEND);
// !@#(* aqua ui #($*(( that turtle-neck wearing #(** (#$@)(
// os9 seems to work if bg of component is set, but x still a bastard
if (Base.isMacOS()) {
yesButton.setBackground(bgcolor[PROMPT]);
noButton.setBackground(bgcolor[PROMPT]);
cancelButton.setBackground(bgcolor[PROMPT]);
okButton.setBackground(bgcolor[PROMPT]);
sendButton.setBackground(bgcolor[SERIAL]);
}
setLayout(null);
yesButton.addActionListener(this);
noButton.addActionListener(this);
cancelButton.addActionListener(this);
okButton.addActionListener(this);
sendButton.addActionListener(this);
add(yesButton);
add(noButton);
add(cancelButton);
add(okButton);
add(sendButton);
yesButton.setVisible(false);
noButton.setVisible(false);
cancelButton.setVisible(false);
okButton.setVisible(false);
sendButton.setVisible(false);
editField = new JTextField();
editField.addActionListener(this);
//if (Base.platform != Base.MACOSX) {
editField.addKeyListener(new KeyAdapter() {
// no-op implemented because of a jikes bug
//protected void noop() { }
//public void keyPressed(KeyEvent event) {
//System.out.println("pressed " + event + " " + KeyEvent.VK_SPACE);
//}
// use keyTyped to catch when the feller is actually
// added to the text field. with keyTyped, as opposed to
// keyPressed, the keyCode will be zero, even if it's
// enter or backspace or whatever, so the keychar should
// be used instead. grr.
public void keyTyped(KeyEvent event) {
//System.out.println("got event " + event + " " +
// KeyEvent.VK_SPACE);
int c = event.getKeyChar();
if (mode == EDIT) {
if (c == KeyEvent.VK_ENTER) { // accept the input
String answer = editField.getText();
editor.sketch.nameCode(answer);
unedit();
event.consume();
// easier to test the affirmative case than the negative
} else if ((c == KeyEvent.VK_BACK_SPACE) ||
(c == KeyEvent.VK_DELETE) ||
(c == KeyEvent.VK_RIGHT) ||
(c == KeyEvent.VK_LEFT) ||
(c == KeyEvent.VK_UP) ||
(c == KeyEvent.VK_DOWN) ||
(c == KeyEvent.VK_HOME) ||
(c == KeyEvent.VK_END) ||
(c == KeyEvent.VK_SHIFT)) {
//System.out.println("nothing to see here");
//noop();
} else if (c == KeyEvent.VK_ESCAPE) {
unedit();
editor.buttons.clear();
event.consume();
} else if (c == KeyEvent.VK_SPACE) {
//System.out.println("got a space");
// if a space, insert an underscore
//editField.insert("_", editField.getCaretPosition());
/* tried to play nice and see where it got me
editField.dispatchEvent(new KeyEvent(editField,
KeyEvent.KEY_PRESSED,
System.currentTimeMillis(),
0, 45, '_'));
*/
//System.out.println("start/end = " +
// editField.getSelectionStart() + " " +
// editField.getSelectionEnd());
String t = editField.getText();
//int p = editField.getCaretPosition();
//editField.setText(t.substring(0, p) + "_" + t.substring(p));
//editField.setCaretPosition(p+1);
int start = editField.getSelectionStart();
int end = editField.getSelectionEnd();
editField.setText(t.substring(0, start) + "_" +
t.substring(end));
editField.setCaretPosition(start+1);
//System.out.println("consuming event");
event.consume();
} else if ((c == '_') || (c == '.') || // allow .pde and .java
((c >= 'A') && (c <= 'Z')) ||
((c >= 'a') && (c <= 'z'))) {
// everything fine, catches upper and lower
//noop();
} else if ((c >= '0') && (c <= '9')) {
// getCaretPosition == 0 means that it's the first char
// and the field is empty.
// getSelectionStart means that it *will be* the first
// char, because the selection is about to be replaced
// with whatever is typed.
if ((editField.getCaretPosition() == 0) ||
(editField.getSelectionStart() == 0)) {
// number not allowed as first digit
//System.out.println("bad number bad");
event.consume();
}
} else {
event.consume();
//System.out.println("code is " + code + " char = " + c);
}
}
//System.out.println("code is " + code + " char = " + c);
}
});
add(editField);
editField.setVisible(false);
serialField = new JTextField();
serialField.addActionListener(this);
serialField.addKeyListener(new KeyAdapter() {
public void keyTyped(KeyEvent event) {
int c = event.getKeyChar();
if (c == KeyEvent.VK_ENTER) { // accept the input
editor.serialPort.write(serialField.getText());
event.consume();
serialField.setText("");
}
}});
add(serialField);
serialField.setVisible(false);
String[] serialRateStrings = {
"300","1200","2400","4800","9600","14400",
"19200","28800","38400","57600","115200"
};
serialRates = new JComboBox();
if (Base.isMacOS())
serialRates.setBackground(bgcolor[SERIAL]);
for (int i = 0; i < serialRateStrings.length; i++)
serialRates.addItem(serialRateStrings[i] + " baud");
serialRates.setSelectedItem(
Preferences.get("serial.debug_rate") + " baud");
serialRates.addActionListener(this);
add(serialRates);
serialRates.setVisible(false);
}
}
protected void setButtonBounds() {
int top = (sizeH - Preferences.BUTTON_HEIGHT) / 2;
int eachButton = Preferences.GUI_SMALL + Preferences.BUTTON_WIDTH;
int cancelLeft = sizeW - eachButton;
int noLeft = cancelLeft - eachButton;
int yesLeft = noLeft - eachButton;
yesButton.setLocation(yesLeft, top);
noButton.setLocation(noLeft, top);
cancelButton.setLocation(cancelLeft, top);
editField.setLocation(yesLeft - Preferences.BUTTON_WIDTH, top);
serialField.setLocation(yesLeft - Preferences.BUTTON_WIDTH, top);
okButton.setLocation(noLeft, top);
serialRates.setLocation(0, top);
sendButton.setLocation(cancelLeft, top);
yesButton.setSize( Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT);
noButton.setSize( Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT);
cancelButton.setSize( Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT);
okButton.setSize( Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT);
sendButton.setSize( Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT);
serialRates.setSize( 3*Preferences.BUTTON_WIDTH/2, Preferences.BUTTON_HEIGHT);
editField.setSize( 2*Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT);
serialField.setSize( 3*Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT);
}
public Dimension getPreferredSize() {
return getMinimumSize();
}
public Dimension getMinimumSize() {
return new Dimension(300, Preferences.GRID_SIZE);
}
public Dimension getMaximumSize() {
return new Dimension(3000, Preferences.GRID_SIZE);
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == noButton) {
// shut everything down, clear status, and return
unprompt();
// don't need to save changes
editor.checkModified2();
} else if (e.getSource() == yesButton) {
// answer was in response to "save changes?"
unprompt();
editor.handleSave(true);
editor.checkModified2();
} else if (e.getSource() == cancelButton) {
// don't do anything, don't continue with checkModified2
if (mode == PROMPT) unprompt();
else if (mode == EDIT) unedit();
editor.buttons.clear();
} else if (e.getSource() == okButton) {
// answering to "save as..." question
String answer = editField.getText();
//editor.handleSaveAs2(answer);
editor.sketch.nameCode(answer);
unedit();
} else if (e.getSource() == sendButton) {
editor.serialPort.write(serialField.getText());
serialField.setText("");
} else if (e.getSource() == serialRates) {
String wholeString = (String) serialRates.getSelectedItem();
String rateString = wholeString.substring(0, wholeString.indexOf(' '));
int rate = Integer.parseInt(rateString);
Preferences.set("serial.debug_rate", rateString);
editor.serialPort.dispose();
try {
editor.serialPort = new Serial(true);
} catch (SerialException err) {
editor.error(err);
}
}
}
}

View File

@ -1,592 +0,0 @@
/*
Library.java - Library System for Wiring
Copyright (c) 2006 Nicholas Zambetti. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
package processing.app;
import processing.app.syntax.*;
import java.io.*;
import java.util.*;
import java.util.zip.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import processing.core.*;
/*
* Provides information about and builds a library
*/
public class Library implements MessageConsumer{
private File libFolder;
private File utilityFolder;
private LibraryManager libManager;
RunnerException exception;
static final String BUGS_URL = "https://developer.berlios.de/bugs/?group_id=3590";
static final String SUPER_BADNESS = "Compiler error, please submit this code to " + BUGS_URL;
/*
* Create a Library
*/
public Library(LibraryManager manager, File folder)
{
libFolder = folder;
libManager = manager;
utilityFolder = getUtilityFolder();
// for debug output
/*
System.out.println("library: " + getName());
System.out.println("folder: " + getFolder());
System.out.println("utility: " + utilityFolder);
System.out.println("built: " + isBuilt());
System.out.println("buildable: " + isBuildable());
System.out.println("o files: " + getObjectFiles().length);
System.out.println("c files: " + getCSourceFiles().length);
System.out.println("cpp files: " + getCPPSourceFiles().length);
*/
}
/*
* Directory of library
* @return File object of library's folder
*/
public File getFolder()
{
return libFolder;
}
/*
* The name of library
* @return String with library name, derived from folder
* note: this will be eventually taken from xml description file
*/
public String getName()
{
return libFolder.getName();
}
/*
* Tests if library is built
* @return True if library has .o files, false otherwise
*/
public boolean isBuilt()
{
if(getObjectFiles().length >= (getCSourceFiles().length + getCPPSourceFiles().length)){
return true;
}
return false;
}
/*
* Tests if library is buildable
* @return True if library has source files, false otherwise
*/
public boolean isBuildable()
{
if(0 < (getCSourceFiles().length + getCPPSourceFiles().length)){
return true;
}
return false;
}
/*
* Tests if library is unbuilt but buildable
* @return True if library has .cpp files but no .o files, false otherwise
*/
public boolean isUnbuiltBuildable()
{
if(isBuildable()){
if(!isBuilt()){
return true;
}
}
return false;
}
/*
* Scans for library "utility" folder
* @return File object of library's "utility" folder, or null
*/
private File getUtilityFolder()
{
FileFilter filter = new FileFilter() {
public boolean accept(File file) {
if(file.isDirectory()){
if((file.getName()).equalsIgnoreCase("utility")){
return true;
}
}
return false;
}
};
File[] files = libFolder.listFiles(filter);
if(files.length > 0){
return files[0];
}
return null;
}
/*
* Finds examples folder
* @return "examples" folder as file object or null
*/
private File getExamplesFolder()
{
FileFilter filter = new FileFilter() {
public boolean accept(File file) {
if(file.isDirectory()){
if((file.getName()).equalsIgnoreCase("examples")){
return true;
}
}
return false;
}
};
File[] files = libFolder.listFiles(filter);
if(files.length > 0){
return files[0];
}
return null;
}
/*
* Populates example menu or submenu with files
*/
private void populateWithExamples(File folder, JMenu menu, ActionListener listener) {
FileFilter onlyfolders = new FileFilter() {
public boolean accept(File file) {
return file.isDirectory();
}
};
File[] folders = folder.listFiles(onlyfolders);
File file;
JMenu submenu;
JMenuItem item;
for(int i = 0; i < folders.length; ++i){
file = new File(folders[i], folders[i].getName() + ".pde");
if(file.exists()){
item = new JMenuItem(folders[i].getName());
item.setActionCommand(file.getAbsolutePath());
item.addActionListener(listener);
menu.add(item);
}else{
submenu = new JMenu(folders[i].getName());
populateWithExamples(folders[i], submenu, listener);
menu.add(submenu);
}
}
}
/*
* Builds and returns an examples menu
* @return JMenu object with example files, or null if none
*/
public JMenu getExamplesMenu(ActionListener listener) {
JMenu submenu;
File examplesFolder = getExamplesFolder();
if(null != examplesFolder){
submenu = new JMenu("Library-" + getName());
populateWithExamples(examplesFolder, submenu, listener);
return submenu;
}
return null;
}
/*
* List of object files for linking
* @return Array of object files as File objects
*/
private File[] getObjectFiles(File folder)
{
FileFilter onlyObjectFiles = new FileFilter() {
public boolean accept(File file) {
return (file.getName()).endsWith(".o");
}
};
return folder.listFiles(onlyObjectFiles);
}
public File[] getObjectFiles()
{
if(null == utilityFolder){
return getObjectFiles(libFolder);
}
File[] libraryObjects = getObjectFiles(libFolder);
File[] utilityObjects = getObjectFiles(utilityFolder);
File[] objects = new File[libraryObjects.length + utilityObjects.length];
System.arraycopy(libraryObjects, 0, objects, 0, libraryObjects.length);
System.arraycopy(utilityObjects, 0, objects, libraryObjects.length, utilityObjects.length);
return objects;
}
/*
* List of header source files for inclusion
* @return Array of header source files as File objects
*/
public File[] getHeaderFiles()
{
FileFilter onlyHFiles = new FileFilter() {
public boolean accept(File file) {
return (file.getName()).endsWith(".h");
}
};
return libFolder.listFiles(onlyHFiles);
}
/*
* List of library's C source files for compiling
* @return Array of C source files as File objects
*/
private File[] getCSourceFiles(File folder)
{
FileFilter onlyCFiles = new FileFilter() {
public boolean accept(File file) {
return (file.getName()).endsWith(".c");
}
};
return folder.listFiles(onlyCFiles);
}
private File[] getCSourceFiles()
{
if(null == utilityFolder){
return getCSourceFiles(libFolder);
}
File[] librarySources = getCSourceFiles(libFolder);
File[] utilitySources = getCSourceFiles(utilityFolder);
File[] sources = new File[librarySources.length + utilitySources.length];
System.arraycopy(librarySources, 0, sources, 0, librarySources.length);
System.arraycopy(utilitySources, 0, sources, librarySources.length, utilitySources.length);
return sources;
}
/*
* List of C++ source files for compiling
* @return Array of C++ source files as File objects
*/
private File[] getCPPSourceFiles(File folder)
{
FileFilter onlyCPPFiles = new FileFilter() {
public boolean accept(File file) {
return (file.getName()).endsWith(".cpp");
}
};
return folder.listFiles(onlyCPPFiles);
}
private File[] getCPPSourceFiles()
{
if(null == utilityFolder){
return getCPPSourceFiles(libFolder);
}
File[] librarySources = getCPPSourceFiles(libFolder);
File[] utilitySources = getCPPSourceFiles(utilityFolder);
File[] sources = new File[librarySources.length + utilitySources.length];
System.arraycopy(librarySources, 0, sources, 0, librarySources.length);
System.arraycopy(utilitySources, 0, sources, librarySources.length, utilitySources.length);
return sources;
}
/*
* Attempt to build library
* @return true on successful build, false otherwise
*/
public boolean build() throws RunnerException
{
// fail if library is not buildable (contains no sources)
if(!isBuildable()){
return false;
}
String userdir = System.getProperty("user.dir") + File.separator;
String avrBasePath;
if(Base.isMacOS()) {
avrBasePath = new String("hardware/tools/avr/bin/");
}
else if(Base.isLinux()) {
avrBasePath = new String("");
}
else {
avrBasePath = new String(userdir + "hardware/tools/avr/bin/");
}
String[] baseCompileCommandC = new String[] {
avrBasePath + "avr-gcc",
"-c",
"-g",
"-Os",
"-Wall",
"-ffunction-sections", // place each function in its own section
"-fdata-sections",
"-mmcu=" + Preferences.get("boards." + Preferences.get("board") + ".build.mcu"),
"-DF_CPU=" + Preferences.get("boards." + Preferences.get("board") + ".build.f_cpu"),
"-I" + libManager.getTarget().getPath(),
"-I" + getFolder(),
};
String[] baseCompileCommandCPP = new String[] {
avrBasePath + "avr-g++",
"-c",
"-g",
"-Os",
"-Wall",
"-fno-exceptions",
"-ffunction-sections", // place each function in its own section
"-fdata-sections",
"-mmcu=" + Preferences.get("boards." + Preferences.get("board") + ".build.mcu"),
"-DF_CPU=" + Preferences.get("boards." + Preferences.get("board") + ".build.f_cpu"),
"-I" + libManager.getTarget().getPath(),
"-I" + getFolder(),
};
// use built lib directories in include paths when searching for headers
// this allows libs to use other libs easily
int extraSpots = 2; // two spots for file path and -o portions
utilityFolder = getUtilityFolder(); // refresh status of utility folder
if(null != utilityFolder){
extraSpots = 3; // an extra spot for utility folder as include
}
String[] libDirs = libManager.getFolderPaths();
String[] compileCommandC = new String[baseCompileCommandC.length + libDirs.length + extraSpots];
String[] compileCommandCPP = new String[baseCompileCommandCPP.length + libDirs.length + extraSpots];
System.arraycopy(baseCompileCommandC, 0, compileCommandC, 0, baseCompileCommandC.length);
System.arraycopy(baseCompileCommandCPP, 0, compileCommandCPP, 0, baseCompileCommandCPP.length);
for (int i = 0; i < libDirs.length; ++i) {
compileCommandC[baseCompileCommandC.length + i] = "-I" + libDirs[i];
compileCommandCPP[baseCompileCommandCPP.length + i] = "-I" + libDirs[i];
}
// add this library's "utility" folder to inclusion paths
if(null != utilityFolder){
compileCommandC[compileCommandC.length - 3] = "-I" + utilityFolder.getPath();
compileCommandCPP[compileCommandCPP.length - 3] = "-I" + utilityFolder.getPath();
}
File[] sourcesC = getCSourceFiles();
File[] sourcesCPP = getCPPSourceFiles();
// execute the compiler, and create threads to deal
// with the input and error streams
//
int result = 0;
try {
String pathSansExtension;
Process process;
boolean compiling = true;
// compile c sources
for(int i = 0; i < sourcesC.length; ++i) {
pathSansExtension = sourcesC[i].getPath();
pathSansExtension = pathSansExtension.substring(0, pathSansExtension.length() - 2); // -2 because ".c"
compileCommandC[compileCommandC.length - 2] = sourcesC[i].getPath();
compileCommandC[compileCommandC.length - 1] = "-o" + pathSansExtension + ".o";
process = Runtime.getRuntime().exec(compileCommandC);
new MessageSiphon(process.getInputStream(), this);
new MessageSiphon(process.getErrorStream(), this);
// wait for the process to finish. if interrupted
// before waitFor returns, continue waiting
//
compiling = true;
while (compiling) {
try {
result = process.waitFor();
//System.out.println("result is " + result);
compiling = false;
} catch (InterruptedException ignored) { }
}
if (exception != null) {
exception.hideStackTrace = true;
throw exception;
}
if(result != 0){
return false;
}
}
// compile c++ sources
for(int i = 0; i < sourcesCPP.length; ++i) {
pathSansExtension = sourcesCPP[i].getPath();
pathSansExtension = pathSansExtension.substring(0, pathSansExtension.length() - 4); // -4 because ".cpp"
compileCommandCPP[compileCommandCPP.length - 2] = sourcesCPP[i].getPath();
compileCommandCPP[compileCommandCPP.length - 1] = "-o" + pathSansExtension + ".o";
process = Runtime.getRuntime().exec(compileCommandCPP);
new MessageSiphon(process.getInputStream(), this);
new MessageSiphon(process.getErrorStream(), this);
// wait for the process to finish. if interrupted
// before waitFor returns, continue waiting
//
compiling = true;
while (compiling) {
try {
result = process.waitFor();
//System.out.println("result is " + result);
compiling = false;
} catch (InterruptedException ignored) { }
}
if (exception != null) {
exception.hideStackTrace = true;
throw exception;
}
if(result != 0){
return false;
}
}
} catch (Exception e) {
String msg = e.getMessage();
if ((msg != null) && (msg.indexOf("avr-gcc: not found") != -1)) {
Base.showWarning("Compiler error",
"Could not find the compiler.\n" +
"avr-gcc is missing from your PATH,\n" +
"see readme.txt for help.", null);
return false;
} else if ((msg != null) && (msg.indexOf("avr-g++: not found") != -1)) {
Base.showWarning("Compiler error",
"Could not find the compiler.\n" +
"avr-g++ is missing from your PATH,\n" +
"see readme.txt for help.", null);
return false;
} else {
e.printStackTrace();
result = -1;
}
}
// an error was queued up by message()
if (exception != null) {
throw exception;
}
if (result != 0 && result != 1 ) {
Base.openURL(BUGS_URL);
throw new RunnerException(SUPER_BADNESS);
}
// success would mean that 'result' is set to zero
return (result == 0); // ? true : false;
}
/**
* Part of the MessageConsumer interface, this is called
* whenever a piece (usually a line) of error message is spewed
* out from the compiler. The errors are parsed for their contents
* and line number, which is then reported back to Editor.
*/
public void message(String inString) {
// This receives messages as full lines, so a newline needs
// to be added as they're printed to the console.
// always print all compilation output for library writers!
String outString = "";
// shorten file paths so that they are friendlier
int start = 0;
int end = 0;
String substring = libFolder.getPath() + File.separator;
StringBuffer result = new StringBuffer();
while ((end = inString.indexOf(substring, start)) >= 0) {
result.append(inString.substring(start, end));
start = end + substring.length();
}
result.append(inString.substring(start));
outString = result.toString();
System.err.print(outString);
// prepare error for throwing
if (inString.indexOf("error") != -1){
exception = new RunnerException("Error building library \"" + getName() + "\"");
}
}
/**
* Handles loading of keywords file.
* It is recommended that a # sign be used for comments
* inside keywords.txt.
*/
public void addSyntaxColors(PdeKeywords keywords) {
File keywordsFile = new File(libFolder.getPath() + File.separator + "keywords.txt");
// do not bother if no keywords file to read
// should reprimand negligent library writers?!
if(!keywordsFile.exists() || !keywordsFile.canRead()){
return;
}
try{
// open file stream in the verbose java way
InputStream input = new FileInputStream(keywordsFile);
InputStreamReader isr = new InputStreamReader(input);
BufferedReader reader = new BufferedReader(isr);
String line = null;
while ((line = reader.readLine()) != null) {
// skip empty and whitespace lines
if (line.trim().length() == 0){
continue;
}
// skip lines without tabs
if (line.indexOf('\t') == -1){
continue;
}
String pieces[] = PApplet.split(line, '\t');
if (pieces.length >= 2) {
String keyword = pieces[0].trim();
String coloring = pieces[1].trim();
if (coloring.length() > 0) {
// text will be KEYWORD or LITERAL
boolean isKey = (coloring.charAt(0) == 'K');
// KEYWORD1 -> 0, KEYWORD2 -> 1, etc
int num = coloring.charAt(coloring.length() - 1) - '1';
byte id = (byte)((isKey ? Token.KEYWORD1 : Token.LITERAL1) + num);
//System.out.println("got " + (isKey ? "keyword" : "literal") + (num+1) + " for " + keyword);
PdeKeywords.getKeywordColoring().add(keyword, id);
}
}
}
// close file stream
reader.close();
} catch (Exception e) {
Base.showError("Problem Loading Keywords",
"Could not load or interpret 'keywords.txt' in " + getName() + " library.\n" +
"This must be corrected before distributing.", e);
}
}
}

View File

@ -1,271 +0,0 @@
/*
LibraryManager.java - Library System for Wiring
Copyright (c) 2006-07 Nicholas Zambetti. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
package processing.app;
import processing.app.syntax.*;
import java.io.*;
import java.util.*;
import java.util.zip.*;
import java.awt.event.*;
import javax.swing.*;
/*
* Provides information about and builds libraries
*/
public class LibraryManager {
private File libDir;
private List libraries = new ArrayList();
private Target target;
/*
* Create a LibraryManager.
*/
public LibraryManager() throws IOException
{
String userDir = System.getProperty("user.dir") + File.separator;
libDir = new File(
((!Base.isMacOS()) ? "" : userDir) + "hardware" + File.separator +
"libraries");
target = new Target(
System.getProperty("user.dir") + File.separator + "hardware" +
File.separator + "cores",
Preferences.get("boards." + Preferences.get("board") + ".build.core"));
refreshLibraries();
}
public Target getTarget()
{
return target;
}
/*
* Scans for libraries and refreshes internal list
*/
private void refreshLibraries()
{
FileFilter onlyDirs = new FileFilter() {
public boolean accept(File file) {
return file.isDirectory();
}
};
libraries.clear();
File[] libs = libDir.listFiles(onlyDirs);
for(int i = 0; i < libs.length; ++i){
libraries.add(new Library(this, libs[i]));
}
}
/*
* Returns a collection of all library objects
* @return A read-only collection of Library objects
*/
public Collection getAll() {
refreshLibraries();
return Collections.unmodifiableList(libraries);
}
/*
* Returns a collection of all built library objects
* @return A read-only collection of built Library objects
*/
public Collection getBuiltLibraries() {
refreshLibraries();
List builtLibraries = new ArrayList();
Library library;
ListIterator libIterator = libraries.listIterator();
while(libIterator.hasNext()){
library = (Library)libIterator.next();
if(library.isBuilt()){
builtLibraries.add(library);
}
}
return Collections.unmodifiableList(builtLibraries);
}
/*
* Returns a collection of all buildable library objects
* @return A read-only collection of built Library objects
*/
public Collection getLibrariesToBuild() {
refreshLibraries();
List buildableLibraries = new ArrayList();
Library library;
ListIterator libIterator = libraries.listIterator();
while(libIterator.hasNext()){
library = (Library)libIterator.next();
if(library.isUnbuiltBuildable()){
buildableLibraries.add(library);
}
}
return Collections.unmodifiableList(buildableLibraries);
}
/*
* Rebuilds built libraries
* @return Number of libraries built as int, -1 & exception on error
*/
public int rebuildAllBuilt() throws RunnerException {
Collection builtLibraries = getBuiltLibraries();
Library library;
Iterator libIterator = builtLibraries.iterator();
int countBuilt = 0;
while(libIterator.hasNext()){
library = (Library)libIterator.next();
//System.out.println("Building library \"" + library.getName() + "\"");
try {
if(library.build()){
++countBuilt;
}else{
return -1;
}
}catch (RunnerException re) {
throw new RunnerException(re.getMessage());
} catch (Exception ex) {
throw new RunnerException(ex.toString());
}
}
return countBuilt;
}
/*
* Gathers paths to object files
* @return Array of strings of paths to object files
*/
public String[] getObjectFiles() {
ArrayList filesArrayList = new ArrayList();
Collection builtLibraries = getBuiltLibraries();
Library library;
File[] files;
Iterator libIterator = builtLibraries.iterator();
while(libIterator.hasNext()){
library = (Library)libIterator.next();
files = library.getObjectFiles();
for(int i = 0; i < files.length; ++i){
filesArrayList.add(files[i].getPath());
}
}
String[] filesArray = new String[filesArrayList.size()];
filesArrayList.toArray(filesArray);
return filesArray;
}
/*
* Gathers filenames of header files
* @return Array of strings of filenames of header files
*/
public String[] getHeaderFiles() {
ArrayList filesArrayList = new ArrayList();
Collection builtLibraries = getBuiltLibraries();
Library library;
File[] files;
Iterator libIterator = builtLibraries.iterator();
while(libIterator.hasNext()){
library = (Library)libIterator.next();
files = library.getHeaderFiles();
for(int i = 0; i < files.length; ++i){
filesArrayList.add(files[i].getName());
}
}
String[] filesArray = new String[filesArrayList.size()];
filesArrayList.toArray(filesArray);
return filesArray;
}
/*
* Gathers paths to library folders
* @return Array of strings of paths to library folders
*/
public String[] getFolderPaths() {
ArrayList foldersArrayList = new ArrayList();
//Collection builtLibraries = getBuiltLibraries();
Collection libraries = getAll();
Library library;
//Iterator libIterator = builtLibraries.iterator();
Iterator libIterator = libraries.iterator();
while(libIterator.hasNext()){
library = (Library)libIterator.next();
foldersArrayList.add(library.getFolder().getPath());
}
String[] foldersArray = new String[foldersArrayList.size()];
foldersArrayList.toArray(foldersArray);
return foldersArray;
}
/*
* Builds unbuilt libraries
* @return Number of libraries built as int, -1 & exception on error
*/
public int buildAllUnbuilt() throws RunnerException {
Collection buildableLibraries = getLibrariesToBuild();
Library library;
Iterator libIterator = buildableLibraries.iterator();
int countBuilt = 0;
while(libIterator.hasNext()){
library = (Library)libIterator.next();
//System.out.println("Building library \"" + library.getName() + "\"");
try {
if(library.build()){
++countBuilt;
}else{
return -1;
}
}catch (RunnerException re) {
throw new RunnerException(re.getMessage());
} catch (Exception ex) {
throw new RunnerException(ex.toString());
}
}
return countBuilt;
}
/*
* Populates examples menu with library folders
*/
public void populateExamplesMenu(JMenu examplesMenu, ActionListener listener) {
Library library;
Collection libraries = getBuiltLibraries();
Iterator iterator = libraries.iterator();
JMenu libraryExamples;
while(iterator.hasNext()){
library = (Library)iterator.next();
libraryExamples = library.getExamplesMenu(listener);
if(null != libraryExamples){
examplesMenu.add(libraryExamples);
}
}
}
/*
* Add syntax coloring
*/
public void addSyntaxColoring(PdeKeywords keywords) {
Library library;
Collection libraries = getBuiltLibraries();
Iterator iterator = libraries.iterator();
while(iterator.hasNext()){
library = (Library)iterator.next();
library.addSyntaxColors(keywords);
}
}
}

View File

@ -1,646 +0,0 @@
/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
Part of the Processing project - http://processing.org
Copyright (c) 2004-05 Ben Fry and Casey Reas
Copyright (c) 2001-04 Massachusetts Institute of Technology
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package processing.app;
import processing.core.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.lang.reflect.*;
import java.util.*;
import com.oroinc.text.regex.*;
/**
* Runs a compiled java applet, whether as an external application
* or internally as an applet object in a window.
*/
public class Runner implements MessageConsumer {
PApplet applet;
RunnerException exception;
Window window;
PrintStream leechErr;
//String className;
Editor editor;
Sketch sketch;
boolean newMessage;
int messageLineCount;
boolean foundMessageSource;
Process process;
SystemOutSiphon processInput;
OutputStream processOutput;
MessageSiphon processError;
public Runner(Sketch sketch, Editor editor) {
this.sketch = sketch;
this.editor = editor;
}
public void start(Point windowLocation) throws RunnerException {
//System.out.println(" externalRuntime is " + sketch.externalRuntime);
/* this.leechErr = new PrintStream(new MessageStream(this));
try {
if (editor.presenting) {
startPresenting();
} else if (sketch.externalRuntime) {
startExternalRuntime(windowLocation);
} else {
startInternal(windowLocation);
}
} catch (Exception e) {
// this will pass through to the first part of message
// this handles errors that happen inside setup()
e.printStackTrace();
// make sure applet is in use
if (applet != null) applet.finished = true;
leechErr.println(PApplet.LEECH_WAKEUP);
e.printStackTrace(this.leechErr);
}
*/
}
public void startPresenting() throws Exception {
Vector params = new Vector();
params.add("java");
String options = Preferences.get("run.options");
/* if (options.length() > 0) {
String pieces[] = PApplet.split(options, ' ');
for (int i = 0; i < pieces.length; i++) {
String p = pieces[i].trim();
if (p.length() > 0) {
params.add(p);
}
}
}
params.add("-Djava.library.path=" +
sketch.libraryPath +
File.pathSeparator +
System.getProperty("java.library.path"));
params.add("-cp");
params.add(sketch.classPath + Sketchbook.librariesClassPath);
params.add("processing.core.PApplet");
params.add(PApplet.ARGS_EXTERNAL);
params.add(PApplet.ARGS_PRESENT);
params.add(PApplet.ARGS_PRESENT_STOP_COLOR + "=" +
Preferences.get("run.present.stop.color"));
params.add(PApplet.ARGS_BGCOLOR + "=" +
Preferences.get("run.present.bgcolor"));
params.add(PApplet.ARGS_DISPLAY + "=" +
Preferences.get("run.display"));
params.add(PApplet.ARGS_SKETCH_FOLDER + "=" +
sketch.folder.getAbsolutePath());
params.add(sketch.mainClassName);
String command[] = new String[params.size()];
params.copyInto(command);
//PApplet.println(command);
process = Runtime.getRuntime().exec(command);
processInput = new SystemOutSiphon(process.getInputStream());
processError = new MessageSiphon(process.getErrorStream(), this);
processOutput = process.getOutputStream();
*/
}
public void startExternalRuntime(Point windowLocation) throws Exception {
// if there was a saved location (this guy has been run more than
// once) then windowLocation will be set to the last position of
// the sketch window. this will be passed to the PApplet runner
// using something like --external=e30,20 where the e stands for
// exact. otherwise --external=x,y for just the regular positioning.
/* Point editorLocation = editor.getLocation();
String location =
(windowLocation != null) ?
(PApplet.ARGS_LOCATION + "=" +
windowLocation.x + "," + windowLocation.y) :
(PApplet.ARGS_EDITOR_LOCATION + "=" +
editorLocation.x + "," + editorLocation.y);
// this as prefix made the code folder bug go away, but killed stdio
//"cmd", "/c", "start",
// all params have to be stored as separate items,
// so a growable array needs to be used. i.e. -Xms128m -Xmx1024m
// will throw an error if it's shoved into a single array element
Vector params = new Vector();
params.add("java");
String options = Preferences.get("run.options");
if (options.length() > 0) {
String pieces[] = PApplet.split(options, ' ');
for (int i = 0; i < pieces.length; i++) {
String p = pieces[i].trim();
if (p.length() > 0) {
params.add(p);
}
}
}
// sketch.libraryPath might be ""
// librariesClassPath will always have sep char prepended
params.add("-Djava.library.path=" +
sketch.libraryPath +
File.pathSeparator +
System.getProperty("java.library.path"));
params.add("-cp");
params.add(sketch.classPath + Sketchbook.librariesClassPath);
params.add("processing.core.PApplet");
params.add(location);
params.add(PApplet.ARGS_EXTERNAL);
params.add(PApplet.ARGS_DISPLAY + "=" +
Preferences.get("run.display"));
params.add(PApplet.ARGS_SKETCH_FOLDER + "=" +
sketch.folder.getAbsolutePath());
params.add(sketch.mainClassName);
String command[] = new String[params.size()];
params.copyInto(command);
//PApplet.println(command);
process = Runtime.getRuntime().exec(command);
processInput = new SystemOutSiphon(process.getInputStream());
processError = new MessageSiphon(process.getErrorStream(), this);
processOutput = process.getOutputStream();
*/ }
public void startInternal(Point windowLocation) throws Exception {
/* Point editorLocation = editor.getLocation();
//Insets editorInsets = editor.getInsets();
int windowX = editorLocation.x;
int windowY = editorLocation.y + editor.getInsets().top;
RunnerClassLoader loader = new RunnerClassLoader();
Class c = loader.loadClass(sketch.mainClassName);
applet = (PApplet) c.newInstance();
window = new Frame(sketch.name); // use ugly window
((Frame)window).setResizable(false);
if (editor.icon != null) {
((Frame)window).setIconImage(editor.icon);
}
window.pack(); // to get a peer, size set later, need for insets
applet.leechErr = leechErr;
applet.folder = sketch.folder.getAbsolutePath();
applet.frame = (Frame) window;
applet.init();
//applet.start();
while ((applet.width == 0) && !applet.finished) {
try {
if (applet.exception != null) {
throw new RunnerException(applet.exception.getMessage());
}
Thread.sleep(5);
} catch (InterruptedException e) { }
}
window.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
stop();
editor.doClose();
}
});
applet.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
stop();
editor.doClose();
}
}
});
window.add(applet);
Dimension screen =
Toolkit.getDefaultToolkit().getScreenSize();
window.setLayout(null);
Insets insets = window.getInsets();
int minW = Preferences.getInteger("run.window.width.minimum");
int minH = Preferences.getInteger("run.window.height.minimum");
int windowW =
Math.max(applet.width, minW) + insets.left + insets.right;
int windowH =
Math.max(applet.height, minH) + insets.top + insets.bottom;
if (windowX - windowW > 10) { // if it fits to the left of the window
window.setBounds(windowX - windowW, windowY, windowW, windowH);
} else { // if it fits inside the editor window
windowX = editorLocation.x + Preferences.GRID_SIZE * 2; // 66
windowY = editorLocation.y + Preferences.GRID_SIZE * 2; // 66
if ((windowX + windowW > screen.width - Preferences.GRID_SIZE) ||
(windowY + windowH > screen.height - Preferences.GRID_SIZE)) {
// otherwise center on screen
windowX = (screen.width - windowW) / 2;
windowY = (screen.height - windowH) / 2;
}
window.setBounds(windowX, windowY, windowW, windowH); //ww, wh);
}
Color windowBgColor = Preferences.getColor("run.window.bgcolor");
window.setBackground(windowBgColor);
int usableH = windowH - insets.top - insets.bottom;
applet.setBounds((windowW - applet.width)/2,
insets.top + (usableH - applet.height) / 2,
windowW, windowH);
applet.setVisible(true); // no effect
if (windowLocation != null) {
window.setLocation(windowLocation);
}
window.show();
applet.requestFocus(); // necessary for key events
*/
}
public void stop() {
/* // check for null in case stop is called during compilation
if (applet != null) {
applet.stop();
// above avoids NullPointerExceptions
// but still threading is too complex, and so
// some boogers are being left behind
applet = null;
} else if (process != null) { // running externally
try {
processOutput.write(PApplet.EXTERNAL_STOP);
processOutput.flush();
} catch (IOException e) {
close();
}
}
*/
}
public void close() {
/* //if (window != null) window.hide();
if (window != null) {
//System.err.println("disposing window");
window.dispose();
window = null;
}
if (process != null) {
try {
process.destroy();
} catch (Exception e) {
//System.err.println("(ignored) error while destroying");
//e.printStackTrace();
}
process = null;
}
*/
}
// made synchronized for rev 87
synchronized public void message(String s) {
//System.out.println("M" + s.length() + ":" + s.trim()); // + "MMM" + s.length());
// this eats the CRLFs on the lines.. oops.. do it later
//if (s.trim().length() == 0) return;
// this is PApplet sending a message (via System.out.println)
// that signals that the applet has been quit.
// if (s.indexOf(PApplet.EXTERNAL_QUIT) == 0) {
//System.out.println("external: quit");
// editor.doClose();
// return;
// }
// this is the PApplet sending us a message that the applet
// is being moved to a new window location
// if (s.indexOf(PApplet.EXTERNAL_MOVE) == 0) {
// String nums = s.substring(s.indexOf(' ') + 1).trim();
// int space = nums.indexOf(' ');
// int left = Integer.parseInt(nums.substring(0, space));
// int top = Integer.parseInt(nums.substring(space + 1));
// editor.appletLocation = new Point(left, top);
// //System.out.println("external: move to " + left + " " + top);
//// return;
// }
// this is PApplet sending a message saying "i'm about to spew
// a stack trace because an error occurred during PApplet.run()"
// if (s.indexOf(PApplet.LEECH_WAKEUP) == 0) {
// newMessage being set to 'true' means that the next time
// message() is called, expect the first line of the actual
// // error message & stack trace to be sent from the applet.
// newMessage = true;
// return; // this line ignored
// }
// these are used for debugging, in case there are concerns
// that some errors aren't coming through properly
/*
if (s.length() > 2) {
System.err.println(newMessage);
System.err.println("message " + s.length() + ":" + s);
}
*/
// always shove out the mesage, since it might not fall under
// the same setup as we're expecting
System.err.print(s);
//System.err.println("[" + s.length() + "] " + s);
System.err.flush();
// exit here because otherwise the exception name
// may be titled with a blank string
if (s.trim().length() == 0) return;
// annoying, because it seems as though the terminators
// aren't being sent properly
//System.err.println(s);
//if (newMessage && s.length() > 2) {
if (newMessage) {
exception = new RunnerException(s); // type of java ex
exception.hideStackTrace = true;
//System.out.println("setting ex type to " + s);
newMessage = false;
foundMessageSource = false;
messageLineCount = 0;
} else {
messageLineCount++;
/*
java.lang.NullPointerException
at javatest.<init>(javatest.java:5)
at Temporary_2425_1153.draw(Temporary_2425_1153.java:11)
at PApplet.nextFrame(PApplet.java:481)
at PApplet.run(PApplet.java:428)
at java.lang.Thread.run(Unknown Source)
*/
if (!foundMessageSource) {
// " at javatest.<init>(javatest.java:5)"
// -> "javatest.<init>(javatest.java:5)"
int afterAt = s.indexOf("at") + 3;
//if (afterAt == -1) {
if (afterAt == 2) { // means indexOf was -1
//System.err.println(s); // stop double-printing exceptions
return;
}
s = s.substring(afterAt + 1);
// "javatest.<init>(javatest.java:5)"
// -> "javatest.<init>" and "(javatest.java:5)"
int startParen = s.indexOf('(');
// at javatest.<init>(javatest.java:5)
String pkgClassFxn = null;
//String fileLine = null;
int codeIndex = -1;
int lineNumber = -1;
if (startParen == -1) {
pkgClassFxn = s;
} else {
pkgClassFxn = s.substring(0, startParen);
// "(javatest.java:5)"
String fileAndLine = s.substring(startParen + 1);
int stopParen = fileAndLine.indexOf(')');
//fileAndLine = fileAndLine.substring(0, fileAndLine.length() - 1);
fileAndLine = fileAndLine.substring(0, stopParen);
//System.out.println("file 'n line " + fileAndLine);
//if (!fileAndLine.equals("Unknown Source")) {
// "javatest.java:5"
int colonIndex = fileAndLine.indexOf(':');
if (colonIndex != -1) {
String filename = fileAndLine.substring(0, colonIndex);
// "javatest.java" and "5"
//System.out.println("filename = " + filename);
//System.out.println("pre0 = " + sketch.code[0].preprocName);
//for (int i = 0; i < sketch.codeCount; i++) {
//System.out.println(i + " " + sketch.code[i].lineOffset + " " +
// sketch.code[i].preprocName);
//}
lineNumber =
Integer.parseInt(fileAndLine.substring(colonIndex + 1)) - 1;
for (int i = 0; i < sketch.codeCount; i++) {
SketchCode code = sketch.code[i];
//System.out.println(code.preprocName + " " + lineNumber + " " +
// code.preprocOffset);
if (((code.preprocName == null) &&
(lineNumber >= code.preprocOffset)) ||
((code.preprocName != null) &&
code.preprocName.equals(filename))) {
codeIndex = i;
//System.out.println("got codeindex " + codeIndex);
//break;
//} else if (
}
}
if (codeIndex != -1) {
//System.out.println("got line num " + lineNumber);
// in case this was a tab that got embedded into the main .java
lineNumber -= sketch.code[codeIndex].preprocOffset;
// this may have a paren on the end, if so need to strip
// down to just the digits
/*
int lastNumberIndex = colonIndex + 1;
while ((lastNumberIndex < fileAndLine.length()) &&
Character.isDigit(fileAndLine.charAt(lastNumberIndex))) {
lastNumberIndex++;
}
*/
// lineNumber is 1-indexed, but editor wants zero-indexed
// getMessage() will be what's shown in the editor
exception =
new RunnerException(exception.getMessage(),
codeIndex, lineNumber, -1);
exception.hideStackTrace = true;
foundMessageSource = true;
}
}
}
editor.error(exception);
/*
int index = s.indexOf(className + ".java");
if (index != -1) {
int len = (className + ".java").length();
String lineNumberStr = s.substring(index + len + 1);
index = lineNumberStr.indexOf(')');
lineNumberStr = lineNumberStr.substring(0, index);
try {
exception.line = Integer.parseInt(lineNumberStr) - 1; //2;
} catch (NumberFormatException e) { }
//e.printStackTrace(); // a recursive error waiting to happen?
// if nfe occurs, who cares, still send the error on up
editor.error(exception);
*/
/*
// WARNING THESE ARE DISABLED!!
} else if ((index = s.indexOf(className + ".class")) != -1) {
// code to check for:
// at Temporary_484_3845.loop(Compiled Code)
// would also probably get:
// at Temporary_484_3845.loop
// which (i believe) is used by the mac and/or jview
String functionStr = s.substring(index +
(className + ".class").length() + 1);
index = functionStr.indexOf('(');
if (index != -1) {
functionStr = functionStr.substring(0, index);
}
exception = new RunnerException(//"inside \"" + functionStr + "()\": " +
exception.getMessage() +
" inside " + functionStr + "() " +
"[add Compiler.disable() to setup()]");
editor.error(exception);
// this will fall through in tihs example:
// at Temporary_4636_9696.pootie(Compiled Code)
// at Temporary_4636_9696.loop(Temporary_4636_9696.java:24)
// because pootie() (re)sets the exception title
// and throws it, but then the line number gets set
// because of the line that comes after
*/
} else if (messageLineCount > 10) { // 5 -> 10 for 0088
// this means the class name may not be mentioned
// in the stack trace.. this is just a general purpose
// error, but needs to make it through anyway.
// so if five lines have gone past, might as well signal
messageLineCount = -100;
exception = new RunnerException(exception.getMessage());
exception.hideStackTrace = true;
editor.error(exception);
} else {
//System.err.print(s);
}
//System.out.println("got it " + s);
}
}
//////////////////////////////////////////////////////////////
/**
* Siphons from an InputStream of System.out (from a Process)
* and sends it to the real System.out.
*/
class SystemOutSiphon implements Runnable {
InputStream input;
Thread thread;
public SystemOutSiphon(InputStream input) {
this.input = input;
thread = new Thread(this);
// unless this is set to min, it seems to hork the app
// since it's in charge of stuffing the editor console with strings
// maybe it's time to get rid of/fix that friggin console
// ...disabled for 0075, with 0074's fix for code folder hanging
// this only seems to make the console unresponsive
//thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
}
public void run() {
byte boofer[] = new byte[256];
while (Thread.currentThread() == thread) {
try {
// can't use a buffered reader here because incremental
// print statements are interesting too.. causes some
// disparity with how System.err gets spewed, oh well.
int count = input.read(boofer, 0, boofer.length);
if (count == -1) {
thread = null;
} else {
System.out.print(new String(boofer, 0, count));
//System.out.flush();
}
} catch (IOException e) {
// this is prolly because the app was quit & the stream broken
//e.printStackTrace(System.out);
//e.printStackTrace();
thread = null;
} catch (Exception e) {
//System.out.println("SystemOutSiphon: i just died in your arms tonight");
// on mac os x, this will spew a "Bad File Descriptor" ex
// each time an external app is shut down.
//e.printStackTrace();
thread = null;
//System.out.println("");
}
//System.out.println("SystemOutSiphon: out");
//thread = null;
}
}
}
}

View File

@ -1,128 +0,0 @@
/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
Based on Simple1.2ClassLoader.java - simple Java 1.2 class loader
Copyright (c) 1999 Ken McCrary, All Rights Reserved.
Permission to use, copy, modify, and distribute this software
and its documentation for NON-COMMERCIAL purposes and without
fee is hereby granted provided that this copyright notice
appears in all copies.
KEN MCCRARY MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE
SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING
BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. KEN MCCRARY
SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT
OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
*/
package processing.app;
import java.io.*;
import java.net.*;
import java.util.*;
import java.util.jar.*;
/**
* Simple class loader adapted for Processing.
* <P>
* Based on code from Ken McCrary.
*/
public class RunnerClassLoader extends ClassLoader {
String buildFolderPath;
RunnerClassLoader() {
buildFolderPath = Base.getBuildFolder().getAbsolutePath();
}
/**
* This is the method where the task of class loading
* is delegated to our custom loader.
*
* @param name the name of the class
* @return the resulting <code>Class</code> object
* @exception ClassNotFoundException if the class could not be found
*/
protected Class findClass(String name) throws ClassNotFoundException {
FileInputStream fi = null;
try {
String path =
buildFolderPath + File.separator + name.replace('.', '/');
//System.out.println("(from " + path + ")");
fi = new FileInputStream(path + ".class");
byte[] classBytes = new byte[fi.available()];
fi.read(classBytes);
//definePackage(name);
return defineClass(name, classBytes, 0, classBytes.length);
} catch (Exception e) {
// could not find the class, so indicate the problem with an exception
throw new ClassNotFoundException(name);
} finally {
if (fi != null) {
try {
fi.close();
} catch (Exception e) { }
}
}
}
/**
* Identify where to load a resource from, resources for
* this simple ClassLoader are in a directory name "store"
*
* @param name the resource name
* @return URL for resource or null if not found
*/
protected URL findResource(String name) {
String path =
buildFolderPath + File.separator + name.replace('.', '/');
File searchResource = new File(path, name);
//URL result = null;
if (searchResource.exists()) {
try {
return searchResource.toURL();
} catch (MalformedURLException mfe) { }
}
//return result;
return null;
}
/**
* Used for identifying resources from multiple URLS
* Since our simple Classloader only has one repository
* the returned Enumeration contains 0 to 1 items
*
* @param name the resource name
* @return Enumeration of one URL
*/
protected Enumeration findResources(final String name) throws IOException {
// Since we only have a single repository we will only have one
// resource of a particular name, the Enumeration will just return
// this single URL
return new Enumeration() {
URL resource = findResource(name);
public boolean hasMoreElements() {
return ( resource != null ? true : false);
}
public Object nextElement() {
if (!hasMoreElements()) {
throw new NoSuchElementException();
} else {
URL result = resource;
resource = null;
return result;
}
}
};
}
}

View File

@ -1,85 +0,0 @@
/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
Part of the Processing project - http://processing.org
Copyright (c) 2004-05 Ben Fry and Casey Reas
Copyright (c) 2001-04 Massachusetts Institute of Technology
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package processing.app;
/**
* An exception with a line number attached that occurs
* during either compile time or run time.
*/
public class RunnerException extends Exception {
public int file = -1;
public int line = -1;
public int column = -1;
public boolean hideStackTrace;
public RunnerException() { }
public RunnerException(String message) {
super(massage(message));
}
public RunnerException(String message, int line) {
super(massage(message));
this.line = line;
}
public RunnerException(String message, int line, int column) {
super(massage(message));
this.line = line;
this.column = column;
}
public RunnerException(String message, int file, int line, int column) {
super(massage(message));
this.file = file;
this.line = line;
this.column = column;
}
/**
* Nix the java.lang crap out of an exception message
* because it scares the children.
* <P>
* This function must be static to be used with super()
* in each of the constructors above.
*/
static public final String massage(String msg) {
if (msg == null)
return "";
if (msg.indexOf("java.lang.") == 0) {
//int dot = msg.lastIndexOf('.');
msg = msg.substring("java.lang.".length());
}
return msg;
//return (dot == -1) ? msg : msg.substring(dot+1);
}
public void printStackTrace() {
if (!hideStackTrace) {
super.printStackTrace();
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,105 +0,0 @@
/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
SketchCode - data class for a single file inside a sketch
Part of the Processing project - http://processing.org
Copyright (c) 2004-05 Ben Fry and Casey Reas
Copyright (c) 2001-04 Massachusetts Institute of Technology
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package processing.app;
import processing.app.syntax.*;
import java.io.*;
import javax.swing.text.*;
import javax.swing.undo.*;
public class SketchCode {
/** Pretty name (no extension), not the full file name */
public String name;
/** File object for where this code is located */
public File file;
/** Type of code in this tab, Sketch.PDE or Sketch.JAVA */
public int flavor;
/** Text of the program text for this tab */
public String program;
/** Document object for this tab */
public SyntaxDocument document;
/** Undo Manager for this tab, each tab keeps track of their own */
public UndoManager undo; // = new UndoManager();
// saved positions from last time this tab was used
public int selectionStart;
public int selectionStop;
public int scrollPosition;
public boolean modified;
//SketchHistory history; // TODO add history information
String preprocName; // name of .java file after preproc
int preprocOffset; // where this code starts relative to the concat'd code
public SketchCode(String name, File file, int flavor) {
this.name = name;
this.file = file;
this.flavor = flavor;
try {
load();
} catch (IOException e) {
System.err.println("error while loading code " + name);
}
}
/**
* Load this piece of code from a file.
*/
public void load() throws IOException {
program = Base.loadFile(file);
modified = false;
}
/**
* Save this piece of code, regardless of whether the modified
* flag is set or not.
*/
public void save() throws IOException {
// TODO re-enable history
//history.record(s, SketchHistory.SAVE);
Base.saveFile(program, file);
modified = false;
}
/**
* Save this file to another location, used by Sketch.saveAs()
*/
public void saveAs(File newFile) throws IOException {
Base.saveFile(program, newFile);
}
}

View File

@ -1,357 +0,0 @@
/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
SketchHistory - handler for storing history information about a project
Part of the Processing project - http://processing.org
Copyright (c) 2004-05 Ben Fry and Casey Reas
Copyright (c) 2001-04 Massachusetts Institute of Technology
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import java.util.zip.*;
import javax.swing.*;
public class SketchHistory {
Editor editor;
// why things have been saved for history
static final int RUN = 5;
static final int SAVE = 6;
static final int AUTOSAVE = 7;
static final int BEAUTIFY = 8;
static final String HISTORY_SEPARATOR =
"#################################################";
JMenu menu;
// true if the sketch is read-only,
// meaning that no history will be recorded
boolean readOnlySketch;
File historyFile;
String lastRecorded;
ActionListener menuListener;
//public SketchHistory(Editor editor) {
//this.editor = editor;
//}
public SketchHistory(Sketch sketch) {
menu = new JMenu("History");
menuListener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
retrieve(e.getActionCommand());
}
};
}
/// Set the path for the current sketch
public void setPath(String path, boolean readOnlySketch) {
this.readOnlySketch = true;
if (readOnlySketch) return;
historyFile = new File(path, "history.gz");
}
public void attachMenu(JMenu parent) {
//if (Preferences.getBoolean("history.recording")) {
parent.add(menu);
// should leave enabled, since can still get old history
// even if the new stuff isn't being recorded
//menu.setEnabled(Preferences.getBoolean("history.recording"));
//}
}
/// Check to see if history should be recorded.
/// mode is RUN, SAVE, AUTOSAVE, or BEAUTIFY
public void record(String program, int mode) {
if (readOnlySketch) return;
if (!Preferences.getBoolean("history.recording")) return;
if ((lastRecorded != null) &&
(lastRecorded.equals(program))) return;
String modeStr = null;
switch (mode) {
case RUN: modeStr = "run"; break;
case SAVE: modeStr = "save"; break;
case AUTOSAVE: modeStr = "autosave"; break;
case BEAUTIFY: modeStr = "beautify"; break;
}
try {
boolean noPreviousHistory = false;
ByteArrayOutputStream old = null;
if (historyFile.exists()) {
InputStream oldStream = new GZIPInputStream(new BufferedInputStream(new FileInputStream(historyFile)));
old = new ByteArrayOutputStream();
int c = oldStream.read();
while (c != -1) {
old.write(c);
c = oldStream.read();
}
//return out.toByteArray();
oldStream.close();
} else {
noPreviousHistory = true; // rebuild menu
}
OutputStream historyStream =
new GZIPOutputStream(new FileOutputStream(historyFile));
if (old != null) {
historyStream.write(old.toByteArray());
}
PrintWriter historyWriter =
new PrintWriter(new OutputStreamWriter(historyStream));
historyWriter.println();
historyWriter.println(HISTORY_SEPARATOR);
Calendar now = Calendar.getInstance();
// 2002 06 18 11 43 29
// when listing, study for descrepancies.. if all are
// 2002, then don't list the year and soforth.
// for the other end, if all minutes are unique,
// then don't show seconds
int year = now.get(Calendar.YEAR);
int month = now.get(Calendar.MONTH) + 1;
int day = now.get(Calendar.DAY_OF_MONTH);
int hour = now.get(Calendar.HOUR_OF_DAY);
int minute = now.get(Calendar.MINUTE);
int second = now.get(Calendar.SECOND);
String parseDate = year + " " + month + " " + day + " " +
hour + " " + minute + " " + second;
String readableDate = now.getTime().toString();
// increment this so sketchbook won't be mangled
// each time this format has to change
String historyVersion = "1";
//Date date = new Date();
//String datestamp = date.toString();
historyWriter.println(historyVersion + " " + modeStr + " - " +
parseDate + " - " + readableDate);
historyWriter.println();
historyWriter.println(program);
historyWriter.flush(); // ??
lastRecorded = program;
//JMenuItem menuItem = new JMenuItem(modeStr + " - " + readableDate);
JMenuItem menuItem = new JMenuItem(modeStr + " - " + readableDate);
menuItem.addActionListener(menuListener);
menu.insert(menuItem, 2);
historyWriter.flush();
historyWriter.close();
if (noPreviousHistory) {
// to get add the actual menu, to get the 'clear' item in there
//rebuildMenu(historyFile.getPath());
rebuildMenu();
}
} catch (IOException e) {
e.printStackTrace();
}
}
public void retrieve(String selection) {
//System.out.println("sel '" + selection + "'");
String readableDate =
selection.substring(selection.indexOf("-") + 2);
// make history for the current guy
record(editor.textarea.getText(), AUTOSAVE);
// mark editor text as having been edited
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(new GZIPInputStream(new FileInputStream(historyFile))));
String line = null;
int historyCount = 0;
String historyList[] = new String[100];
try {
boolean found = false;
while ((line = reader.readLine()) != null) {
//System.out.println("->" + line);
if (line.equals(HISTORY_SEPARATOR)) {
line = reader.readLine();
if (line.indexOf(readableDate) != -1) { // this is the one
found = true;
break;
}
}
}
if (found) {
// read lines until the next separator
line = reader.readLine(); // ignored
//String sep = System.getProperty("line.separator");
StringBuffer buffer = new StringBuffer();
while ((line = reader.readLine()) != null) {
if (line.equals(HISTORY_SEPARATOR)) break;
//textarea.append(line + sep);
//buffer.append(line + sep); // JTextPane wants only \n going in
buffer.append(line + "\n");
//System.out.println("'" + line + "'");
}
//textarea.editorSetText(buffer.toString());
editor.changeText(buffer.toString(), true);
lastRecorded = editor.textarea.getText();
editor.setSketchModified(false);
} else {
System.err.println("couldn't find history entry for " +
"'" + readableDate + "'");
}
} catch (IOException e) {
e.printStackTrace();
}
} catch (IOException e) {
e.printStackTrace();
}
}
// class HistoryMenuListener implements ActionListener {
// public void actionPerformed(ActionEvent e) {
// editor.selectHistory(e.getActionCommand);
// }
// }
//public void rebuildHistoryMenu(String path) {
//rebuildHistoryMenu(historyMenu, path);
//}
//public void rebuildHistoryMenu(Menu menu, String path) {
public void rebuildMenu() { //String path) {
//if (!recordingHistory) return;
//if (!Preferences.getBoolean("history.recording")) return;
menu.removeAll();
//File hfile = new File(path);
//if (!hfile.exists()) return; // no history yet
if (!historyFile.exists()) return;
JMenuItem item = new JMenuItem("Clear History");
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (!historyFile.delete()) {
//System.err.println("couldn't erase history");
Base.showWarning("History Problem",
"Could not erase history", null);
}
rebuildMenu();
//SketchHistory.this.rebuildMenu(historyFile.getPath());
}
});
menu.add(item);
menu.addSeparator();
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(new GZIPInputStream(new FileInputStream(historyFile))));
String line = null;
int historyCount = 0;
String historyList[] = new String[100];
try {
while ((line = reader.readLine()) != null) {
//while (line = reader.readLine()) {
//while (true) { line = reader.readLine();
//if (line == null) continue;
//System.out.println("line: " + line);
if (line.equals(HISTORY_SEPARATOR)) {
// next line is the good stuff
line = reader.readLine();
int version =
Integer.parseInt(line.substring(0, line.indexOf(' ')));
if (version == 1) {
String whysub = line.substring(2); // after "1 "
String why = whysub.substring(0, whysub.indexOf(" -"));
//System.out.println("'" + why + "'");
String readable = line.substring(line.lastIndexOf("-") + 2);
if (historyList.length == historyCount) {
String temp[] = new String[historyCount*2];
System.arraycopy(historyList, 0, temp, 0, historyCount);
historyList = temp;
}
historyList[historyCount++] = why + " - " + readable;
} // otherwise don't know what to do
}
}
//System.out.println(line);
} catch (IOException e) {
e.printStackTrace();
}
// add the items to the menu in reverse order
//ActionListener historyMenuListener =
// new ActionListener() {
// public void actionPerformed(ActionEvent e) {
// editor.retrieveHistory(e.getActionCommand());
//}
//};
for (int i = historyCount-1; i >= 0; --i) {
JMenuItem mi = new JMenuItem(historyList[i]);
mi.addActionListener(menuListener);
menu.add(mi);
}
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
*/

View File

@ -1,683 +0,0 @@
/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
Part of the Processing project - http://processing.org
Copyright (c) 2004-05 Ben Fry and Casey Reas
Copyright (c) 2001-04 Massachusetts Institute of Technology
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package processing.app;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;
import java.text.*;
import java.util.*;
import java.util.zip.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.text.*;
import javax.swing.undo.*;
import com.apple.mrj.*;
/**
* Handles sketchbook mechanics for the sketch menu and file I/O.
*/
public class Sketchbook {
Editor editor;
JMenu openMenu;
JMenu popupMenu;
//JMenu examples;
JMenu importMenu;
// set to true after the first time it's built.
// so that the errors while building don't show up again.
boolean builtOnce;
//File sketchbookFolder;
//String sketchbookPath; // canonical path
// last file/directory used for file opening
//String handleOpenDirectory;
// opted against this.. in imovie, apple always goes
// to the "Movies" folder, even if that wasn't the last used
// these are static because they're used by Sketch
static File examplesFolder;
static String examplesPath; // canonical path (for comparison)
static File librariesFolder;
static String librariesPath;
// maps imported packages to their library folder
static Hashtable importToLibraryTable = new Hashtable();
// classpath for all known libraries for p5
// (both those in the p5/libs folder and those with lib subfolders
// found in the sketchbook)
static String librariesClassPath;
public Sketchbook(Editor editor) {
this.editor = editor;
// this shouldn't change throughout.. it may as well be static
// but only one instance of sketchbook will be built so who cares
examplesFolder = new File(System.getProperty("user.dir"), "examples");
examplesPath = examplesFolder.getAbsolutePath();
librariesFolder = new File(System.getProperty("user.dir"),
"hardware" + File.separator + "libraries");
librariesPath = librariesFolder.getAbsolutePath();
String sketchbookPath = Preferences.get("sketchbook.path");
// if a value is at least set, first check to see if the
// folder exists. if it doesn't, warn the user that the
// sketchbook folder is being reset.
if (sketchbookPath != null) {
File skechbookFolder = new File(sketchbookPath);
if (!skechbookFolder.exists()) {
Base.showWarning("Sketchbook folder disappeared",
"The sketchbook folder no longer exists,\n" +
"so a new sketchbook will be created in the\n" +
"default location.", null);
sketchbookPath = null;
}
}
if (sketchbookPath == null) {
// by default, set default sketchbook path to the user's
// home folder with 'sketchbook' as a subdirectory of that
/*
File home = new File(System.getProperty("user.home"));
if (Base.platform == Base.MACOSX) {
// on macosx put the sketchbook in the "Documents" folder
home = new File(home, "Documents");
} else if (Base.platform == Base.WINDOWS) {
// on windows put the sketchbook in the "My Documents" folder
home = new File(home, "My Documents");
}
*/
// use a subfolder called 'sketchbook'
//File home = Preferences.getProcessingHome();
//String folderName = Preferences.get("sketchbook.name.default");
//File sketchbookFolder = new File(home, folderName);
//System.out.println("resetting sketchbook path");
File sketchbookFolder = Base.getDefaultSketchbookFolder();
//System.out.println("default is " + sketchbookFolder);
Preferences.set("sketchbook.path",
sketchbookFolder.getAbsolutePath());
if (!sketchbookFolder.exists()) sketchbookFolder.mkdirs();
}
openMenu = new JMenu("Sketchbook");
popupMenu = new JMenu("Sketchbook");
importMenu = new JMenu("Import Library");
}
static public String getSketchbookPath() {
return Preferences.get("sketchbook.path");
}
/**
* Handle creating a sketch folder, return its base .pde file
* or null if the operation was cancelled.
*/
public String handleNew(boolean noPrompt,
boolean shift,
boolean library) throws IOException {
File newbieDir = null;
String newbieName = null;
boolean prompt = Preferences.getBoolean("sketchbook.prompt");
if (shift) prompt = !prompt; // reverse behavior if shift is down
// no sketch has been started, don't prompt for the name if it's
// starting up, just make the farker. otherwise if the person hits
// 'cancel' i'd have to add a thing to make p5 quit, which is silly.
// instead give them an empty sketch, and they can look at examples.
// i hate it when imovie makes you start with that goofy dialog box.
// unless, ermm, they user tested it and people preferred that as
// a way to get started. shite. now i hate myself.
//
if (noPrompt) prompt = false;
if (prompt) {
// prompt for the filename and location for the new sketch
FileDialog fd = new FileDialog(editor,
"Create sketch folder named:",
FileDialog.SAVE);
fd.setDirectory(getSketchbookPath());
fd.show();
String newbieParentDir = fd.getDirectory();
newbieName = fd.getFile();
if (newbieName == null) return null;
newbieName = sanitizeName(newbieName);
newbieDir = new File(newbieParentDir, newbieName);
} else {
// use a generic name like sketch_031008a, the date plus a char
String newbieParentDir = getSketchbookPath();
int index = 0;
SimpleDateFormat formatter = new SimpleDateFormat("yyMMdd");
String purty = formatter.format(new Date());
do {
newbieName = "sketch_" + purty + ((char) ('a' + index));
newbieDir = new File(newbieParentDir, newbieName);
index++;
} while (newbieDir.exists());
}
// make the directory for the new sketch
newbieDir.mkdirs();
// if it's a library, make a library subfolder to tag it as such
if (library) {
new File(newbieDir, "library").mkdirs();
}
// make an empty pde file
File newbieFile = new File(newbieDir, newbieName + ".pde");
new FileOutputStream(newbieFile); // create the file
// TODO this wouldn't be needed if i could figure out how to
// associate document icons via a dot-extension/mime-type scenario
// help me steve jobs, you're my only hope.
// jdk13 on osx, or jdk11
// though apparently still available for 1.4
if (Base.isMacOS()) {
MRJFileUtils.setFileTypeAndCreator(newbieFile,
MRJOSType.kTypeTEXT,
new MRJOSType("Pde1"));
// thank you apple, for changing this @#$)(*
//com.apple.eio.setFileTypeAndCreator(String filename, int, int)
}
// make a note of a newly added sketch in the sketchbook menu
rebuildMenusAsync();
// now open it up
//handleOpen(newbieName, newbieFile, newbieDir);
//return newSketch;
return newbieFile.getAbsolutePath();
}
/**
* Convert to sanitized name and alert the user
* if changes were made.
*/
static public String sanitizeName(String origName) {
String newName = sanitizedName(origName);
if (!newName.equals(origName)) {
Base.showMessage("Naming issue",
"The sketch name had to be modified.\n" +
"You can only use basic letters and numbers\n" +
"to name a sketch (ascii only and no spaces,\n" +
"it can't start with a number, and should be\n" +
"less than 64 characters long)");
}
return newName;
}
/**
* Return true if the name is valid for a Processing sketch.
*/
static public boolean isSanitary(String name) {
return sanitizedName(name).equals(name);
}
/**
* Produce a sanitized name that fits our standards for likely to work.
* <p/>
* Java classes have a wider range of names that are technically allowed
* (supposedly any Unicode name) than what we support. The reason for
* going more narrow is to avoid situations with text encodings and
* converting during the process of moving files between operating
* systems, i.e. uploading from a Windows machine to a Linux server,
* or reading a FAT32 partition in OS X and using a thumb drive.
* <p/>
* This helper function replaces everything but A-Z, a-z, and 0-9 with
* underscores. Also disallows starting the sketch name with a digit.
*/
static public String sanitizedName(String origName) {
char c[] = origName.toCharArray();
StringBuffer buffer = new StringBuffer();
// can't lead with a digit, so start with an underscore
if ((c[0] >= '0') && (c[0] <= '9')) {
buffer.append('_');
}
for (int i = 0; i < c.length; i++) {
if (((c[i] >= '0') && (c[i] <= '9')) ||
((c[i] >= 'a') && (c[i] <= 'z')) ||
((c[i] >= 'A') && (c[i] <= 'Z'))) {
buffer.append(c[i]);
} else {
buffer.append('_');
}
}
// let's not be ridiculous about the length of filenames.
// in fact, Mac OS 9 can handle 255 chars, though it can't really
// deal with filenames longer than 31 chars in the Finder.
// but limiting to that for sketches would mean setting the
// upper-bound on the character limit here to 25 characters
// (to handle the base name + ".class")
if (buffer.length() > 63) {
buffer.setLength(63);
}
return buffer.toString();
}
public String handleOpen() {
// swing's file choosers are ass ugly, so we use the
// native (awt peered) dialogs where possible
FileDialog fd = new FileDialog(editor, //new Frame(),
"Open a Processing sketch...",
FileDialog.LOAD);
//fd.setDirectory(Preferences.get("sketchbook.path"));
//fd.setDirectory(getSketchbookPath());
// only show .pde files as eligible bachelors
// TODO this doesn't seem to ever be used. AWESOME.
fd.setFilenameFilter(new FilenameFilter() {
public boolean accept(File dir, String name) {
//System.out.println("check filter on " + dir + " " + name);
return name.toLowerCase().endsWith(".pde");
}
});
// gimme some money
fd.show();
// what in the hell yu want, boy?
String directory = fd.getDirectory();
String filename = fd.getFile();
// user cancelled selection
if (filename == null) return null;
// this may come in handy sometime
//handleOpenDirectory = directory;
File selection = new File(directory, filename);
return selection.getAbsolutePath();
}
/**
* Asynchronous version of menu rebuild to be used on 'new' and 'save',
* to prevent the interface from locking up until the menus are done.
*/
public void rebuildMenusAsync() {
// disabling the async option for actual release, this hasn't been tested
/*
SwingUtilities.invokeLater(new Runnable() {
public void run() {
rebuildMenus();
}
});
*/
rebuildMenus();
}
/**
* Rebuild the menu full of sketches based on the
* contents of the sketchbook.
*
* Creates a separate JMenu object for the popup,
* because it seems that after calling "getPopupMenu"
* the menu will disappear from its original location.
*/
public void rebuildMenus() {
//EditorConsole.systemOut.println("rebuilding menus");
try {
// rebuild file/open and the toolbar popup menus
buildMenu(openMenu);
builtOnce = true; // disable error messages while loading
buildMenu(popupMenu);
// rebuild the "import library" menu
librariesClassPath = "";
importMenu.removeAll();
/*
if (addLibraries(importMenu, new File(getSketchbookPath()))) {
importMenu.addSeparator();
}
*/
if (addLibraries(importMenu, examplesFolder)) {
importMenu.addSeparator();
}
addLibraries(importMenu, librariesFolder);
//System.out.println("libraries cp is now " + librariesClassPath);
} catch (IOException e) {
Base.showWarning("Problem while building sketchbook menu",
"There was a problem with building the\n" +
"sketchbook menu. Things might get a little\n" +
"kooky around here.", e);
}
//EditorConsole.systemOut.println("done rebuilding menus");
}
public void buildMenu(JMenu menu) {
JMenuItem item;
// rebuild the popup menu
menu.removeAll();
//item = new JMenuItem("Open...");
item = Editor.newJMenuItem("Open...", 'O', false);
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
editor.handleOpen(null);
}
});
menu.add(item);
menu.addSeparator();
try {
boolean sketches =
addSketches(menu, new File(getSketchbookPath()));
if (sketches) menu.addSeparator();
} catch (IOException e) {
e.printStackTrace();
}
ActionListener listener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
editor.handleOpen(e.getActionCommand());
}
};
try {
LibraryManager libManager = new LibraryManager();
JMenu examplesMenu = new JMenu("Examples");
addSketches(examplesMenu, examplesFolder);
libManager.populateExamplesMenu(examplesMenu, listener);
menu.add(examplesMenu);
} catch (IOException e) {
e.printStackTrace();
}
/*
// don't do this until it's finished
// libraries don't show up as proper sketches anyway
try {
if (Preferences.getBoolean("export.library")) {
JMenu librariesMenu = new JMenu("Libraries");
addSketches(librariesMenu, librariesFolder);
menu.add(librariesMenu);
}
} catch (IOException e) {
e.printStackTrace();
}
*/
}
public JMenu getOpenMenu() {
if (openMenu == null) rebuildMenus();
return openMenu;
}
public JPopupMenu getPopupMenu() {
if (popupMenu == null) rebuildMenus();
return popupMenu.getPopupMenu();
}
public JMenu getImportMenu() {
return importMenu;
}
protected boolean addSketches(JMenu menu, File folder) throws IOException {
// skip .DS_Store files, etc
if (!folder.isDirectory()) return false;
String list[] = folder.list();
// if a bad folder or something like that, this might come back null
if (list == null) return false;
// alphabetize list, since it's not always alpha order
// replaced hella slow bubble sort with this feller for 0093
Arrays.sort(list, String.CASE_INSENSITIVE_ORDER);
ActionListener listener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
editor.handleOpen(e.getActionCommand());
}
};
boolean ifound = false;
for (int i = 0; i < list.length; i++) {
if ((list[i].charAt(0) == '.') ||
list[i].equals("CVS")) continue;
File subfolder = new File(folder, list[i]);
if (!subfolder.isDirectory()) continue;
File entry = new File(subfolder, list[i] + ".pde");
// if a .pde file of the same prefix as the folder exists..
if (entry.exists()) {
//String sanityCheck = sanitizedName(list[i]);
//if (!sanityCheck.equals(list[i])) {
if (!Sketchbook.isSanitary(list[i])) {
if (!builtOnce) {
String complaining =
"The sketch \"" + list[i] + "\" cannot be used.\n" +
"Sketch names must contain only basic letters and numbers\n" +
"(ASCII-only with no spaces, " +
"and it cannot start with a number).\n" +
"To get rid of this message, remove the sketch from\n" +
entry.getAbsolutePath();
Base.showMessage("Ignoring sketch with bad name", complaining);
}
continue;
}
JMenuItem item = new JMenuItem(list[i]);
item.addActionListener(listener);
item.setActionCommand(entry.getAbsolutePath());
menu.add(item);
ifound = true;
} else {
// not a sketch folder, but maybe a subfolder containing sketches
JMenu submenu = new JMenu(list[i]);
// needs to be separate var
// otherwise would set ifound to false
boolean found = addSketches(submenu, subfolder); //, false);
if (found) {
menu.add(submenu);
ifound = true;
}
}
}
return ifound; // actually ignored, but..
}
protected boolean addLibraries(JMenu menu, File folder) throws IOException {
// skip .DS_Store files, etc
if (!folder.isDirectory()) return false;
String list[] = folder.list();
// if a bad folder or something like that, this might come back null
if (list == null) return false;
// alphabetize list, since it's not always alpha order
// replaced hella slow bubble sort with this feller for 0093
Arrays.sort(list, String.CASE_INSENSITIVE_ORDER);
ActionListener listener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
editor.sketch.importLibrary(e.getActionCommand());
}
};
boolean ifound = false;
for (int i = 0; i < list.length; i++) {
if ((list[i].charAt(0) == '.') ||
list[i].equals("CVS")) continue;
File subfolder = new File(folder, list[i]);
if (!subfolder.isDirectory()) continue;
//File exported = new File(subfolder, "library");
//File entry = new File(exported, list[i] + ".o");
FileFilter onlyHFiles = new FileFilter() {
public boolean accept(File file) {
return (file.getName()).endsWith(".h");
}
};
// if the folder has header files
if (subfolder.listFiles(onlyHFiles).length > 0) {
// if a .jar file of the same prefix as the folder exists
// inside the 'library' subfolder of the sketch
//if (entry.exists()) {
/*
String sanityCheck = sanitizedName(list[i]);
if (!sanityCheck.equals(list[i])) {
String mess =
"The library \"" + list[i] + "\" cannot be used.\n" +
"Library names must contain only basic letters and numbers.\n" +
"(ascii only and no spaces, and it cannot start with a number)";
Base.showMessage("Ignoring bad sketch name", mess);
continue;
}
*/
/*
// get the path for all .jar files in this code folder
String libraryClassPath =
Compiler.contentsToClassPath(exported);
// grab all jars and classes from this folder,
// and append them to the library classpath
librariesClassPath +=
File.pathSeparatorChar + libraryClassPath;
// need to associate each import with a library folder
String packages[] =
Compiler.packageListFromClassPath(libraryClassPath);
for (int k = 0; k < packages.length; k++) {
//System.out.println(packages[k] + " -> " + exported);
//String already = (String) importToLibraryTable.get(packages[k]);
importToLibraryTable.put(packages[k], exported);
}
*/
JMenuItem item = new JMenuItem(list[i]);
item.addActionListener(listener);
item.setActionCommand(subfolder.getAbsolutePath());
menu.add(item);
ifound = true;
} else { // not a library, but is still a folder, so recurse
JMenu submenu = new JMenu(list[i]);
// needs to be separate var, otherwise would set ifound to false
boolean found = addLibraries(submenu, subfolder);
if (found) {
menu.add(submenu);
ifound = true;
}
}
}
return ifound;
/*return false;*/ }
/**
* Clear out projects that are empty.
*/
public void clean() {
//if (!Preferences.getBoolean("sketchbook.auto_clean")) return;
File sketchbookFolder = new File(getSketchbookPath());
if (!sketchbookFolder.exists()) return;
//String entries[] = new File(userPath).list();
String entries[] = sketchbookFolder.list();
if (entries != null) {
for (int j = 0; j < entries.length; j++) {
//System.out.println(entries[j] + " " + entries.length);
if (entries[j].charAt(0) == '.') continue;
//File prey = new File(userPath, entries[j]);
File prey = new File(sketchbookFolder, entries[j]);
File pde = new File(prey, entries[j] + ".pde");
// make sure this is actually a sketch folder with a .pde,
// not a .DS_Store file or another random user folder
if (pde.exists() &&
(Base.calcFolderSize(prey) == 0)) {
//System.out.println("i want to remove " + prey);
if (Preferences.getBoolean("sketchbook.auto_clean")) {
Base.removeDir(prey);
} else { // otherwise prompt the user
String prompt =
"Remove empty sketch titled \"" + entries[j] + "\"?";
Object[] options = { "Yes", "No" };
int result =
JOptionPane.showOptionDialog(editor,
prompt,
"Housekeeping",
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE,
null,
options,
options[0]);
if (result == JOptionPane.YES_OPTION) {
Base.removeDir(prey);
}
}
}
}
}
}
}

View File

@ -1,131 +0,0 @@
package processing.app;
import javax.swing.SwingUtilities;
/**
* This is the 3rd version of SwingWorker (also known as
* SwingWorker 3), an abstract class that you subclass to
* perform GUI-related work in a dedicated thread. For
* instructions on and examples of using this class, see:
*
* http://java.sun.com/docs/books/tutorial/uiswing/misc/threads.html
*
* Note that the API changed slightly in the 3rd version:
* You must now invoke start() on the SwingWorker after
* creating it.
*/
public abstract class SwingWorker {
private Object value; // see getValue(), setValue()
/**
* Class to maintain reference to current worker thread
* under separate synchronization control.
*/
private static class ThreadVar {
private Thread thread;
ThreadVar(Thread t) { thread = t; }
synchronized Thread get() { return thread; }
synchronized void clear() { thread = null; }
}
private ThreadVar threadVar;
/**
* Get the value produced by the worker thread, or null if it
* hasn't been constructed yet.
*/
protected synchronized Object getValue() {
return value;
}
/**
* Set the value produced by worker thread
*/
private synchronized void setValue(Object x) {
value = x;
}
/**
* Compute the value to be returned by the <code>get</code> method.
*/
public abstract Object construct();
/**
* Called on the event dispatching thread (not on the worker thread)
* after the <code>construct</code> method has returned.
*/
public void finished() {
}
/**
* A new method that interrupts the worker thread. Call this method
* to force the worker to stop what it's doing.
*/
public void interrupt() {
Thread t = threadVar.get();
if (t != null) {
t.interrupt();
}
threadVar.clear();
}
/**
* Return the value created by the <code>construct</code> method.
* Returns null if either the constructing thread or the current
* thread was interrupted before a value was produced.
*
* @return the value created by the <code>construct</code> method
*/
public Object get() {
while (true) {
Thread t = threadVar.get();
if (t == null) {
return getValue();
}
try {
t.join();
}
catch (InterruptedException e) {
Thread.currentThread().interrupt(); // propagate
return null;
}
}
}
/**
* Start a thread that will call the <code>construct</code> method
* and then exit.
*/
public SwingWorker() {
final Runnable doFinished = new Runnable() {
public void run() { finished(); }
};
Runnable doConstruct = new Runnable() {
public void run() {
try {
setValue(construct());
}
finally {
threadVar.clear();
}
SwingUtilities.invokeLater(doFinished);
}
};
Thread t = new Thread(doConstruct);
threadVar = new ThreadVar(t);
}
/**
* Start the worker thread.
*/
public void start() {
Thread t = threadVar.get();
if (t != null) {
t.start();
}
}
}

BIN
app/lib/antlr.jar Normal file

Binary file not shown.

BIN
app/lib/apple.jar Executable file

Binary file not shown.

BIN
app/lib/ecj.jar Normal file

Binary file not shown.

BIN
app/lib/jna.jar Normal file

Binary file not shown.

View File

@ -1,15 +0,0 @@
/CSymbolTable.java/1.1.1.1/Thu Sep 22 15:32:54 2005//
/CToken.java/1.1.1.1/Thu Sep 22 15:32:54 2005//
/ExtendedCommonASTWithHiddenTokens.java/1.1.1.1/Thu Sep 22 15:32:55 2005//
/LineObject.java/1.1.1.1/Thu Sep 22 15:32:55 2005//
/Makefile/1.1.1.1/Thu Sep 22 15:32:55 2005//
/PreprocessorInfoChannel.java/1.1.1.1/Thu Sep 22 15:32:55 2005//
/StdCParser.g/1.1.1.1/Thu Sep 22 15:32:56 2005//
/TNode.java/1.1.1.1/Thu Sep 22 15:32:56 2005//
/TNodeFactory.java/1.1.1.1/Thu Sep 22 15:32:56 2005//
/WEmitter.g/1.4/Thu Sep 22 15:32:56 2005//
/WParser.g/1.4/Thu Sep 22 15:32:57 2005//
/WTreeParser.g/1.2/Thu Sep 22 15:32:57 2005//
/whitespace_test.pde/1.1.1.1/Thu Sep 22 15:32:56 2005//
/PdePreprocessor.java/1.13/Sat Sep 24 11:26:19 2005//
D

View File

@ -1 +0,0 @@
wiring/app/preproc

View File

@ -1 +0,0 @@
:ext:dmellis@wcvs.uniandes.edu.co:/home/cvs/cvsrep

View File

@ -1,21 +0,0 @@
int encoder = 4;
unsigned long speed = 0;
void setup()
{
pinMode(encoder, INPUT);
}
void loop()
{
speed = getspeed();
delay(1000);
}
unsigned long getspeed()
{
unsigned long duration = 0;
duration = pulseIn(encoder, HIGH);
return(duration);
}

View File

@ -1,3 +0,0 @@
void setup();
void loop();
unsigned long getspeed();

View File

@ -1,8 +0,0 @@
void playMessage(prog_uchar* message){
maxStringSize = sizeof(message); // find message size
}
void loop() {
playMessage(signMessage);
}

View File

@ -1,2 +0,0 @@
void playMessage(prog_uchar* message);
void loop();

View File

@ -1,19 +0,0 @@
void setup() // run once, when the sketch starts
{
;
}
void loop() // run over and over again
{
;
}
/*
void loop(){
if (1){
;
}
else if(0){
;
}
} */

View File

@ -1,2 +0,0 @@
void setup();
void loop();

View File

@ -1,132 +0,0 @@
//
// Continually measures temperatures at three points using the Dallas DS18B20 on three
// separate Arduino pins.
//
// Uses the parasitic power mode
//
// Displays to a serial LCD operating at 9600 baud.
//
// Arduino Board DS18B20
//
// +5 VDC
// |
// 4.7K
// 8 ---------------- |----- 2 (DQ) Note that terms 1 and 3 are grounded.
//
// 7 ---- same as above
// 6 ---- same as above
//
// Tx ---------------------------- To Serial LCD (LCD #117)
//
// Peter H Anderson, Baltimore, MD, May 5, '07
void setup()
{
int n, dev_channel[3] = {8, 7, 6}, _1W_Pin;
for (n=0; n<1; n++)
{
_1W_Pin = dev_channel[n];
digitalWrite(_1W_Pin, LOW);
pinMode(_1W_Pin, INPUT); // sets the digital pin as input (logic 1)
}
Serial.begin(9600);
delay(100);
Serial.print("?B40"); // set backlight intensity
delay(100);
}
void loop()
{
int n, dev_channel[3] = {8, 7, 6}, _1W_Pin;
int HighByte, LowByte, TReading, SignBit, Tc_100, Whole, Fract;
for (n=0; n<3; n++)
{
_1W_Pin = dev_channel[n];
OneWireReset(_1W_Pin);
OneWireOutByte(_1W_Pin, 0xcc, 0);
OneWireOutByte(_1W_Pin, 0x44, 1); // perform temperature conversion, strong pullup for one sec
OneWireReset(_1W_Pin);
OneWireOutByte(_1W_Pin, 0xcc, 0);
OneWireOutByte(_1W_Pin, 0xbe, 0);
LowByte = OneWireInByte(_1W_Pin);
HighByte = OneWireInByte(_1W_Pin);
TReading = (HighByte << 8) + LowByte;
SignBit = TReading & 0x8000; // test most sig bit
if (SignBit) // negative
{
TReading = (TReading ^ 0xffff) + 1; // 2's comp
}
Tc_100 = (6 * TReading) + TReading / 4; // multiply by (100 * 0.0625) or 6.25
Whole = Tc_100 / 100; // separate off the whole and fractional portions
Fract = Tc_100 % 100;
if (n==0) // if its the first time, clear the LCD
{
Serial.print("?f");
delay(100);
}
if (SignBit) // If its negative
{
Serial.print("-");
}
Serial.print(Whole);
Serial.print(".");
if (Fract < 10)
{
Serial.print("0");
}
Serial.print(Fract);
Serial.print("?n");
}
delay(5000); // 5 second delay. Adjust as necessary
}
void OneWireReset(int _1W_Pin) // reset. Should improve to act as a presence pulse
{
digitalWrite(_1W_Pin, LOW);
pinMode(_1W_Pin, OUTPUT); // bring low for 500 us
delayMicroseconds(500);
pinMode(_1W_Pin, INPUT);
delayMicroseconds(500);
}
void OneWireOutByte(int _1W_Pin, byte d, byte strong) // output byte d (least sig bit first).
{
byte n;
for(n=8; n!=0; n--)
{
if ((d & 0x01) == 1) // test least sig bit
{
digitalWrite(_1W_Pin, LOW);
pinMode(_1W_Pin, OUTPUT);
delayMicroseconds(5);
pinMode(_1W_Pin, INPUT);
delayMicroseconds(60);
}
else
{
digitalWrite(_1W_Pin, LOW);
pinMode(_1W_Pin, OUTPUT);
delayMicroseconds(60);
pinMode(_1W_Pin, INPUT);
}
d=d>>1; // now the next bit is in the least sig bit position.
}
if(strong)
{
digitalWrite(_1W_Pin, HIGH); // One sec of strong +5 VDC
pinMode(_1W_Pin, OUTPUT);
delay(1000);
pinMode(_1W_Pin, INPUT);
digitalWrite(_1W_Pin, LOW);
}
}

View File

@ -1,4 +0,0 @@
void setup();
void loop();
void OneWireReset(int _1W_Pin);
void OneWireOutByte(int _1W_Pin, byte d, byte strong);

View File

@ -1,16 +0,0 @@
void setup()
{
}
void loop()
{
char cmd[16];
int pin;
pin = atoi(&cmd[1]);
}
/*
// convert string to numeric value
int atoi(char *array) {
}
*/

View File

@ -1,2 +0,0 @@
void setup();
void loop();

View File

@ -1,11 +0,0 @@
void setup()
{
}
void loop()
{
}
void foo(int x, int y, char *z)
{
}

View File

@ -1,3 +0,0 @@
void setup();
void loop();
void foo(int x, int y, char *z);

View File

@ -1,35 +0,0 @@
#include "hello" /* for blah */
int x[] = { 1, 2, 3 };
int y[2] = { 1, 2 };
class Foo {
public:
Foo();
Foo(int x);
int bar() { return x; }
private:
int x;
};
Foo::Foo(int x) : x(x) {}
Foo::Foo() {
x = 0;
}
Foo foo(3);
Foo bar = Foo(2);
void setup() {
}
void
loop (
)
{
}

View File

@ -1,5 +0,0 @@
void setup();
void
loop (
);

View File

@ -1,5 +0,0 @@
abc/* def */ghi
jkl// mno
pqr"stu"vwx
#yz
123

View File

@ -1,5 +0,0 @@
abc ghi
jkl
pqr vwx
123

View File

@ -1 +0,0 @@
abc"d\nef\\\"ghi"jkl//"

View File

@ -1 +0,0 @@
abc jkl

View File

@ -1 +0,0 @@
abc"d\\nef\\\"ghi"jkl//"

View File

@ -1 +0,0 @@
abc jkl

View File

@ -1 +0,0 @@
abc"dnef\\\\\"ghi"jkl//"

View File

@ -1 +0,0 @@
abc jkl

View File

@ -1 +0,0 @@
abc'"'def'"'ghi

View File

@ -1 +0,0 @@
abc def ghi

View File

@ -1,2 +0,0 @@
# abc /* def
ghi */ jkl

View File

@ -1 +0,0 @@
jkl

View File

@ -1 +0,0 @@
abc /* def * ghi */ jkl

View File

@ -1 +0,0 @@
abc jkl

View File

@ -1 +0,0 @@
abc /* def * ghi **/ jkl

View File

@ -1 +0,0 @@
abc jkl

View File

@ -1 +0,0 @@
abc /* def ** ghi **/ jkl

View File

@ -1 +0,0 @@
abc jkl

View File

@ -1,3 +0,0 @@
abc /* def ** ghi ***
jkl *
* // mno **/ pqr

View File

@ -1 +0,0 @@
abc pqr

View File

@ -1,3 +0,0 @@
abc // def /*
ghi
jlk // mno */

View File

@ -1,3 +0,0 @@
abc
ghi
jlk

View File

@ -1,3 +0,0 @@
// /* // */ "
asdf
// /* // */ "

View File

@ -1,3 +0,0 @@
asdf

View File

@ -1,7 +0,0 @@
/*
abc
/*
def
*/
ghi
*/

View File

@ -1,3 +0,0 @@
ghi
*/

View File

@ -1 +0,0 @@
abc"def//ghi"jkl

View File

@ -1 +0,0 @@
abc jkl

View File

@ -1,3 +0,0 @@
abc // def " ghi
jkl
mno // pqr " stu

View File

@ -1,3 +0,0 @@
abc
jkl
mno

View File

@ -1 +0,0 @@
abc"def\\"ghi"jkl//"

View File

@ -1 +0,0 @@
abc ghi

View File

@ -1 +0,0 @@
abc"def\"ghi"jkl

View File

@ -1 +0,0 @@
abc jkl

View File

@ -1 +0,0 @@
abc"def\\\"ghi"jkl//"

View File

@ -1 +0,0 @@
abc jkl

View File

@ -1,5 +0,0 @@
#!/bin/sh
javac -classpath ../../../build/shared/lib/oro.jar test_PdePreprocessor.java
for i in data/t*.cpp; do echo $i; java -classpath ../../../build/shared/lib/oro.jar:. test_PdePreprocessor strip $i | diff - $i.out; done
for i in data/foo*.cpp; do echo $i; java -classpath ../../../build/shared/lib/oro.jar:. test_PdePreprocessor prototypes $i | diff - $i.out; done

View File

@ -1,44 +0,0 @@
import java.io.Reader;
import java.io.File;
import java.io.FileReader;
import java.util.List;
import java.util.ArrayList;
import com.oroinc.text.regex.*;
public class test_PdePreprocessor {
/************************************************************************
Paste from PdePreprocessor.java: strip(), collapseBraces(), prototypes()
************************************************************************/
public static void main(String[] args) {
if (args.length < 2) {
System.err.println("Usage: PreProc [strip|prototypes] <file>");
return;
}
try {
test_PdePreprocessor preproc = new test_PdePreprocessor();
Reader reader = new FileReader(new File(args[1]));
StringBuffer buffer = new StringBuffer();
char[] buf = new char[1024];
int n;
while ((n = reader.read(buf, 0, 1024)) != -1) {
buffer.append(buf, 0, n);
}
if (args[0].equals("strip")) {
System.out.print(preproc.strip(buffer.toString()));
} else {
List prototypes = preproc.prototypes(buffer.toString());
for (int i = 0; i < prototypes.size(); i++) {
System.out.println((String) prototypes.get(i));
}
}
} catch (Exception e) {
System.err.println(e);
}
}
}

View File

@ -0,0 +1,132 @@
package antlr;
/* ANTLR Translator Generator
* Project led by Terence Parr at http://www.jGuru.com
* Software rights: http://www.antlr.org/RIGHTS.html
*
* $Id: ExtendedCommonASTWithHiddenTokens.java 3419 2007-07-16 14:02:05Z fry $
*/
import java.io.*;
//import antlr.*;
import antlr.collections.*;
//import antlr.collections.impl.*;
/** A CommonAST whose initialization copies hidden token
* information from the Token used to create a node.
*/
public class ExtendedCommonASTWithHiddenTokens
extends CommonASTWithHiddenTokens {
public ExtendedCommonASTWithHiddenTokens() {
super();
}
public ExtendedCommonASTWithHiddenTokens(Token tok) {
super(tok);
}
public void initialize(AST ast) {
ExtendedCommonASTWithHiddenTokens a =
(ExtendedCommonASTWithHiddenTokens)ast;
super.initialize(a);
hiddenBefore = a.getHiddenBefore();
hiddenAfter = a.getHiddenAfter();
}
public String getHiddenAfterString() {
CommonHiddenStreamToken t;
StringBuffer hiddenAfterString = new StringBuffer(100);
for ( t = hiddenAfter ; t != null ; t = t.getHiddenAfter() ) {
hiddenAfterString.append(t.getText());
}
return hiddenAfterString.toString();
}
public String getHiddenBeforeString() {
antlr.CommonHiddenStreamToken
child = null,
parent = hiddenBefore;
// if there aren't any hidden tokens here, quietly return
//
if (parent == null) {
return "";
}
// traverse back to the head of the list of tokens before this node
do {
child = parent;
parent = child.getHiddenBefore();
} while (parent != null);
// dump that list
StringBuffer hiddenBeforeString = new StringBuffer(100);
for ( CommonHiddenStreamToken t = child; t != null ;
t = t.getHiddenAfter() ) {
hiddenBeforeString.append(t.getText());
}
return hiddenBeforeString.toString();
}
public void xmlSerializeNode(Writer out)
throws IOException {
StringBuffer buf = new StringBuffer(100);
buf.append("<");
buf.append(getClass().getName() + " ");
buf.append("hiddenBeforeString=\"" +
encode(getHiddenBeforeString()) +
"\" text=\"" + encode(getText()) + "\" type=\"" +
getType() + "\" hiddenAfterString=\"" +
encode(getHiddenAfterString()) + "\"/>");
out.write(buf.toString());
}
public void xmlSerializeRootOpen(Writer out)
throws IOException {
StringBuffer buf = new StringBuffer(100);
buf.append("<");
buf.append(getClass().getName() + " ");
buf.append("hiddenBeforeString=\"" +
encode(getHiddenBeforeString()) +
"\" text=\"" + encode(getText()) + "\" type=\"" +
getType() + "\" hiddenAfterString=\"" +
encode(getHiddenAfterString()) + "\">\n");
out.write(buf.toString());
}
public void xmlSerializeRootClose(Writer out)
throws IOException {
out.write("</" + getClass().getName() + ">\n");
}
public void xmlSerialize(Writer out) throws IOException {
// print out this node and all siblings
for (AST node = this;
node != null;
node = node.getNextSibling()) {
if (node.getFirstChild() == null) {
// print guts (class name, attributes)
((BaseAST)node).xmlSerializeNode(out);
}
else {
((BaseAST)node).xmlSerializeRootOpen(out);
// print children
((BaseAST)node.getFirstChild()).xmlSerialize(out);
// print end tag
((BaseAST)node).xmlSerializeRootClose(out);
}
}
}
}

View File

@ -0,0 +1,221 @@
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
package antlr;
//package processing.app.preproc;
//import antlr.*;
import antlr.collections.impl.BitSet;
/**
* This class provides TokenStreamHiddenTokenFilters with the concept of
* tokens which can be copied so that they are seen by both the hidden token
* stream as well as the parser itself. This is useful when one wants to use
* an existing parser (like the Java parser included with ANTLR) that throws
* away some tokens to create a parse tree which can be used to spit out
* a copy of the code with only minor modifications.
*
* This code is partially derived from the public domain ANLTR TokenStream
*/
public class TokenStreamCopyingHiddenTokenFilter
extends TokenStreamHiddenTokenFilter
implements TokenStream {
protected BitSet copyMask;
CommonHiddenStreamToken hiddenCopy = null;
public TokenStreamCopyingHiddenTokenFilter(TokenStream input) {
super(input);
copyMask = new BitSet();
}
/**
* Indicate that all tokens of type tokenType should be copied. The copy
* is put in the stream of hidden tokens, and the original is returned in the
* stream of normal tokens.
*
* @param tokenType integer representing the token type to copied
*/
public void copy(int tokenType) {
copyMask.add(tokenType);
}
/**
* Create a clone of the important parts of the given token. Note that this
* does NOT copy the hiddenBefore and hiddenAfter fields.
*
* @param t token to partially clone
* @return newly created partial clone
*/
public CommonHiddenStreamToken partialCloneToken(CommonHiddenStreamToken t) {
CommonHiddenStreamToken u = new CommonHiddenStreamToken(t.getType(),
t.getText());
u.setColumn(t.getColumn());
u.setLine(t.getLine());
u.setFilename(t.getFilename());
return u;
}
public void linkAndCopyToken(CommonHiddenStreamToken prev,
CommonHiddenStreamToken monitored) {
// create a copy of the token in the lookahead for use as hidden token
hiddenCopy = partialCloneToken(LA(1));
// attach copy to the previous token, whether hidden or monitored
prev.setHiddenAfter(hiddenCopy);
// if previous token was hidden, set the hiddenBefore pointer of the
// copy to point back to it
if (prev != monitored) {
hiddenCopy.setHiddenBefore(prev);
}
// we don't want the non-hidden copy to link back to the hidden
// copy on the next pass through this function, so we leave
// lastHiddenToken alone
//System.err.println("hidden copy: " + hiddenCopy.toString());
return;
}
private void consumeFirst() throws TokenStreamException {
consume(); // get first token of input stream
// Handle situation where hidden or discarded tokens
// appear first in input stream
CommonHiddenStreamToken p=null;
// while hidden, copied, or discarded scarf tokens
while ( hideMask.member(LA(1).getType()) ||
discardMask.member(LA(1).getType()) ||
copyMask.member(LA(1).getType()) ) {
// if we've hit one of the tokens that needs to be copied, we copy it
// and then break out of the loop, because the parser needs to see it
// too
//
if (copyMask.member(LA(1).getType())) {
// copy the token in the lookahead
hiddenCopy = partialCloneToken(LA(1));
// if there's an existing token before this, link that and the
// copy together
if (p != null) {
p.setHiddenAfter(hiddenCopy);
hiddenCopy.setHiddenBefore(p); // double-link
}
lastHiddenToken = hiddenCopy;
if (firstHidden == null) {
firstHidden = hiddenCopy;
}
// we don't want to consume this token, because it also needs to
// be passed through to the parser, so break out of the while look
// entirely
//
break;
} else if (hideMask.member(LA(1).getType())) {
if (p != null) {
p.setHiddenAfter(LA(1));
LA(1).setHiddenBefore(p); // double-link
}
p = LA(1);
lastHiddenToken = p;
if (firstHidden == null) {
firstHidden = p; // record hidden token if first
}
}
consume();
}
}
/** Return the next monitored token.
* Test the token following the monitored token.
* If following is another monitored token, save it
* for the next invocation of nextToken (like a single
* lookahead token) and return it then.
* If following is unmonitored, nondiscarded (hidden)
* channel token, add it to the monitored token.
*
* Note: EOF must be a monitored Token.
*/
public Token nextToken() throws TokenStreamException {
// handle an initial condition; don't want to get lookahead
// token of this splitter until first call to nextToken
if (LA(1) == null) {
consumeFirst();
}
//System.err.println();
// we always consume hidden tokens after monitored, thus,
// upon entry LA(1) is a monitored token.
CommonHiddenStreamToken monitored = LA(1);
// point to hidden tokens found during last invocation
monitored.setHiddenBefore(lastHiddenToken);
lastHiddenToken = null;
// Look for hidden tokens, hook them into list emanating
// from the monitored tokens.
consume();
CommonHiddenStreamToken prev = monitored;
// deal with as many not-purely-monitored tokens as possible
while ( hideMask.member(LA(1).getType()) ||
discardMask.member(LA(1).getType()) ||
copyMask.member(LA(1).getType()) ) {
if (copyMask.member(LA(1).getType())) {
// copy the token and link it backwards
if (hiddenCopy != null) {
linkAndCopyToken(hiddenCopy, monitored);
} else {
linkAndCopyToken(prev, monitored);
}
// we now need to parse it as a monitored token, so we return, which
// avoids the consume() call at the end of this loop. the next call
// will parse it as a monitored token.
//System.err.println("returned: " + monitored.toString());
return monitored;
} else if (hideMask.member(LA(1).getType())) {
// attach the hidden token to the monitored in a chain
// link forwards
prev.setHiddenAfter(LA(1));
// link backwards
if (prev != monitored) { //hidden cannot point to monitored tokens
LA(1).setHiddenBefore(prev);
} else if (hiddenCopy != null) {
hiddenCopy.setHiddenAfter(LA(1));
LA(1).setHiddenBefore(hiddenCopy);
hiddenCopy = null;
}
//System.err.println("hidden: " + prev.getHiddenAfter().toString() + "\" after: " + prev.toString());
prev = lastHiddenToken = LA(1);
}
consume();
}
// remember the last hidden token for next time around
if (hiddenCopy != null) {
lastHiddenToken = hiddenCopy;
hiddenCopy = null;
}
//System.err.println("returned: " + monitored.toString());
return monitored;
}
}

1277
app/src/antlr/java/java.g Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,326 @@
package antlr;
/** Java 1.3 AST Recognizer Grammar
*
* Author: (see java.g preamble)
*
* This grammar is in the PUBLIC DOMAIN
*/
class JavaTreeParser extends TreeParser;
options {
importVocab = Java;
}
compilationUnit
: (packageDefinition)?
(importDefinition)*
(typeDefinition)*
;
packageDefinition
: #( PACKAGE_DEF identifier )
;
importDefinition
: #( IMPORT identifierStar )
;
typeDefinition
: #(CLASS_DEF modifiers IDENT extendsClause implementsClause objBlock )
| #(INTERFACE_DEF modifiers IDENT extendsClause interfaceBlock )
;
typeSpec
: #(TYPE typeSpecArray)
;
typeSpecArray
: #( ARRAY_DECLARATOR typeSpecArray )
| type
;
type: identifier
| builtInType
;
builtInType
: "void"
| "boolean"
| "byte"
| "char"
| "short"
| "int"
| "float"
| "long"
| "double"
;
modifiers
: #( MODIFIERS (modifier)* )
;
modifier
: "private"
| "public"
| "protected"
| "static"
| "transient"
| "final"
| "abstract"
| "native"
| "threadsafe"
| "synchronized"
| "const"
| "volatile"
| "strictfp"
;
extendsClause
: #(EXTENDS_CLAUSE (identifier)* )
;
implementsClause
: #(IMPLEMENTS_CLAUSE (identifier)* )
;
interfaceBlock
: #( OBJBLOCK
( methodDecl
| variableDef
)*
)
;
objBlock
: #( OBJBLOCK
( ctorDef
| methodDef
| variableDef
| typeDefinition
| #(STATIC_INIT slist)
| #(INSTANCE_INIT slist)
)*
)
;
ctorDef
: #(CTOR_DEF modifiers methodHead (slist)?)
;
methodDecl
: #(METHOD_DEF modifiers typeSpec methodHead)
;
methodDef
: #(METHOD_DEF modifiers typeSpec methodHead (slist)?)
;
variableDef
: #(VARIABLE_DEF modifiers typeSpec variableDeclarator varInitializer)
;
parameterDef
: #(PARAMETER_DEF modifiers typeSpec IDENT )
;
objectinitializer
: #(INSTANCE_INIT slist)
;
variableDeclarator
: IDENT
| LBRACK variableDeclarator
;
varInitializer
: #(ASSIGN initializer)
|
;
initializer
: expression
| arrayInitializer
;
arrayInitializer
: #(ARRAY_INIT (initializer)*)
;
methodHead
: IDENT #( PARAMETERS (parameterDef)* ) (throwsClause)?
;
throwsClause
: #( "throws" (identifier)* )
;
identifier
: IDENT
| #( DOT identifier IDENT )
;
identifierStar
: IDENT
| #( DOT identifier (STAR|IDENT) )
;
slist
: #( SLIST (stat)* )
;
stat: typeDefinition
| variableDef
| expression
| #(LABELED_STAT IDENT stat)
| #("if" expression stat (stat)? )
| #( "for"
#(FOR_INIT (variableDef | elist)?)
#(FOR_CONDITION (expression)?)
#(FOR_ITERATOR (elist)?)
stat
)
| #("while" expression stat)
| #("do" stat expression)
| #("break" (IDENT)? )
| #("continue" (IDENT)? )
| #("return" (expression)? )
| #("switch" expression (caseGroup)*)
| #("throw" expression)
| #("synchronized" expression stat)
| tryBlock
| slist // nested SLIST
// uncomment to make assert JDK 1.4 stuff work
| #("assert" expression (expression)?)
| EMPTY_STAT
;
caseGroup
: #(CASE_GROUP (#("case" expression) | "default")+ slist)
;
tryBlock
: #( "try" slist (handler)* (#("finally" slist))? )
;
handler
: #( "catch" parameterDef slist )
;
elist
: #( ELIST (expression)* )
;
expression
: #(EXPR expr)
;
expr: #(QUESTION expr expr expr) // trinary operator
| #(ASSIGN expr expr) // binary operators...
| #(PLUS_ASSIGN expr expr)
| #(MINUS_ASSIGN expr expr)
| #(STAR_ASSIGN expr expr)
| #(DIV_ASSIGN expr expr)
| #(MOD_ASSIGN expr expr)
| #(SR_ASSIGN expr expr)
| #(BSR_ASSIGN expr expr)
| #(SL_ASSIGN expr expr)
| #(BAND_ASSIGN expr expr)
| #(BXOR_ASSIGN expr expr)
| #(BOR_ASSIGN expr expr)
| #(LOR expr expr)
| #(LAND expr expr)
| #(BOR expr expr)
| #(BXOR expr expr)
| #(BAND expr expr)
| #(NOT_EQUAL expr expr)
| #(EQUAL expr expr)
| #(LT expr expr)
| #(GT expr expr)
| #(LE expr expr)
| #(GE expr expr)
| #(SL expr expr)
| #(SR expr expr)
| #(BSR expr expr)
| #(PLUS expr expr)
| #(MINUS expr expr)
| #(DIV expr expr)
| #(MOD expr expr)
| #(STAR expr expr)
| #(INC expr)
| #(DEC expr)
| #(POST_INC expr)
| #(POST_DEC expr)
| #(BNOT expr)
| #(LNOT expr)
| #("instanceof" expr expr)
| #(UNARY_MINUS expr)
| #(UNARY_PLUS expr)
| primaryExpression
;
primaryExpression
: IDENT
| #( DOT
( expr
( IDENT
| arrayIndex
| "this"
| "class"
| #( "new" IDENT elist )
| "super"
)
| #(ARRAY_DECLARATOR typeSpecArray)
| builtInType ("class")?
)
)
| arrayIndex
| #(METHOD_CALL primaryExpression elist)
| ctorCall
| #(TYPECAST typeSpec expr)
| newExpression
| constant
| "super"
| "true"
| "false"
| "this"
| "null"
| typeSpec // type name used with instanceof
;
ctorCall
: #( CTOR_CALL elist )
| #( SUPER_CTOR_CALL
( elist
| primaryExpression elist
)
)
;
arrayIndex
: #(INDEX_OP expr expression)
;
constant
: NUM_INT
| CHAR_LITERAL
| STRING_LITERAL
| NUM_FLOAT
| NUM_DOUBLE
| NUM_LONG
;
newExpression
: #( "new" type
( newArrayDeclarator (arrayInitializer)?
| elist (objBlock)?
)
)
;
newArrayDeclarator
: #( ARRAY_DECLARATOR (newArrayDeclarator)? (expression)? )
;

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,297 @@
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
Part of the Processing project - http://processing.org
Copyright (c) 2008 Ben Fry and Casey Reas
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package processing.app;
import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import processing.core.PApplet;
import processing.app.debug.*;
/**
* Class to handle running Processing from the command line.
* <PRE>
* --help Show the help text.
*
* --sketch=&lt;name&rt; Specify the sketch folder (required)
* --output=&lt;name&rt; Specify the output folder (required and
* cannot be the same as the sketch folder.)
*
* --preprocess Preprocess a sketch into .java files.
* --build Preprocess and compile a sketch into .class files.
* --run Preprocess, compile, and run a sketch.
* --present Preprocess, compile, and run a sketch full screen.
*
* --export-applet Export an applet.
* --export-application Export an application.
* --platform Specify the platform (export to application only).
* Should be one of 'windows', 'macosx', or 'linux'.
*
* --preferences=&lt;file&rt; Specify a preferences file to use (optional).
* </PRE>
*
* To build the command line version, first build for your platform,
* then cd to processing/build/cmd and type 'dist.sh'. This will create a
* usable installation plus a zip file of the same.
*
* @author fry
*/
public class Commander implements RunnerListener {
static final String helpArg = "--help";
static final String preprocArg = "--preprocess";
static final String buildArg = "--build";
static final String runArg = "--run";
static final String presentArg = "--present";
static final String sketchArg = "--sketch=";
static final String outputArg = "--output=";
static final String exportAppletArg = "--export-applet";
static final String exportApplicationArg = "--export-application";
static final String platformArg = "--platform=";
static final String preferencesArg = "--preferences=";
static final int HELP = -1;
static final int PREPROCESS = 0;
static final int BUILD = 1;
static final int RUN = 2;
static final int PRESENT = 3;
static final int EXPORT_APPLET = 4;
static final int EXPORT_APPLICATION = 5;
Sketch sketch;
static public void main(String[] args) {
// init the platform so that prefs and other native code is ready to go
Base.initPlatform();
// make sure a full JDK is installed
Base.initRequirements();
// run static initialization that grabs all the prefs
//Preferences.init(null);
// launch command line handler
new Commander(args);
}
public Commander(String[] args) {
String sketchFolder = null;
String pdePath = null; // path to the .pde file
String outputPath = null;
String preferencesPath = null;
int platformIndex = PApplet.platform; // default to this platform
int mode = HELP;
for (String arg : args) {
if (arg.length() == 0) {
// ignore it, just the crappy shell script
} else if (arg.equals(helpArg)) {
// mode already set to HELP
} else if (arg.equals(buildArg)) {
mode = BUILD;
} else if (arg.equals(runArg)) {
mode = RUN;
} else if (arg.equals(presentArg)) {
mode = PRESENT;
} else if (arg.equals(preprocArg)) {
mode = PREPROCESS;
} else if (arg.equals(exportAppletArg)) {
mode = EXPORT_APPLET;
} else if (arg.equals(exportApplicationArg)) {
mode = EXPORT_APPLICATION;
} else if (arg.startsWith(platformArg)) {
String platformStr = arg.substring(platformArg.length());
platformIndex = Base.getPlatformIndex(platformStr);
if (platformIndex == -1) {
complainAndQuit(platformStr + " should instead be " +
"'windows', 'macosx', or 'linux'.");
}
} else if (arg.startsWith(sketchArg)) {
sketchFolder = arg.substring(sketchArg.length());
File sketchy = new File(sketchFolder);
File pdeFile = new File(sketchy, sketchy.getName() + ".pde");
pdePath = pdeFile.getAbsolutePath();
} else if (arg.startsWith(outputArg)) {
outputPath = arg.substring(outputArg.length());
} else {
complainAndQuit("I don't know anything about " + arg + ".");
}
}
if ((outputPath == null) &&
(mode == PREPROCESS || mode == BUILD ||
mode == RUN || mode == PRESENT)) {
complainAndQuit("An output path must be specified when using " +
preprocArg + ", " + buildArg + ", " +
runArg + ", or " + presentArg + ".");
}
if (mode == HELP) {
printCommandLine(System.out);
System.exit(0);
}
// --present --platform=windows "--sketch=/Applications/Processing 0148/examples/Basics/Arrays/Array" --output=test-build
File outputFolder = new File(outputPath);
if (!outputFolder.exists()) {
if (!outputFolder.mkdirs()) {
complainAndQuit("Could not create the output folder.");
}
}
// run static initialization that grabs all the prefs
// (also pass in a prefs path if that was specified)
Preferences.init(preferencesPath);
if (sketchFolder == null) {
complainAndQuit("No sketch path specified.");
} else if (outputPath.equals(pdePath)) {
complainAndQuit("The sketch path and output path cannot be identical.");
} else if (!pdePath.toLowerCase().endsWith(".pde")) {
complainAndQuit("Sketch path must point to the main .pde file.");
} else {
//Sketch sketch = null;
boolean success = false;
try {
sketch = new Sketch(null, pdePath);
if (mode == PREPROCESS) {
success = sketch.preprocess(outputPath) != null;
} else if (mode == BUILD) {
success = sketch.build(outputPath) != null;
} else if (mode == RUN || mode == PRESENT) {
String className = sketch.build(outputPath);
if (className != null) {
success = true;
Runner runner =
new Runner(sketch, className, mode == PRESENT, this);
runner.launch();
} else {
success = false;
}
} else if (mode == EXPORT_APPLET) {
if (outputPath != null) {
success = sketch.exportApplet(outputPath);
} else {
String target = sketchFolder + File.separatorChar + "applet";
success = sketch.exportApplet(target);
}
} else if (mode == EXPORT_APPLICATION) {
if (outputPath != null) {
success = sketch.exportApplication(outputPath, platformIndex);
} else {
//String sketchFolder =
// pdePath.substring(0, pdePath.lastIndexOf(File.separatorChar));
outputPath =
sketchFolder + File.separatorChar +
"application." + Base.getPlatformName(platformIndex);
success = sketch.exportApplication(outputPath, platformIndex);
}
}
System.exit(success ? 0 : 1);
} catch (RunnerException re) {
statusError(re);
} catch (IOException e) {
e.printStackTrace();
System.exit(1);
}
}
}
public void statusError(String message) {
System.err.println(message);
}
public void statusError(Exception exception) {
if (exception instanceof RunnerException) {
RunnerException re = (RunnerException) exception;
// format the runner exception like emacs
//blah.java:2:10:2:13: Syntax Error: This is a big error message
String filename = sketch.getCode(re.getCodeIndex()).getFileName();
int line = re.getCodeLine();
int column = re.getCodeColumn();
if (column == -1) column = 0;
// TODO if column not specified, should just select the whole line.
System.err.println(filename + ":" +
line + ":" + column + ":" +
line + ":" + column + ":" + " " + re.getMessage());
} else {
exception.printStackTrace();
}
}
static void complainAndQuit(String lastWords) {
printCommandLine(System.err);
System.err.println(lastWords);
System.exit(1);
}
static void printCommandLine(PrintStream out) {
out.println("Processing " + Base.VERSION_NAME + " rocks the console.");
out.println();
out.println("--help Show this help text.");
out.println();
out.println("--sketch=<name> Specify the sketch folder (required)");
out.println("--output=<name> Specify the output folder (required and");
out.println(" cannot be the same as the sketch folder.)");
out.println();
out.println("--preprocess Preprocess a sketch into .java files.");
out.println("--build Preprocess and compile a sketch into .class files.");
out.println("--run Preprocess, compile, and run a sketch.");
out.println("--present Preprocess, compile, and run a sketch full screen.");
out.println();
out.println("--export-applet Export an applet.");
out.println("--export-application Export an application.");
out.println("--platform Specify the platform (export to application only).");
out.println(" Should be one of 'windows', 'macosx', or 'linux'.");
out.println();
out.println("--preferences=<file> Specify a preferences file to use (optional).");
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +1,9 @@
/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ /* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/* /*
Part of the Processing project - http://processing.org Part of the Processing project - http://processing.org
Copyright (c) 2004-05 Ben Fry and Casey Reas Copyright (c) 2004-06 Ben Fry and Casey Reas
Copyright (c) 2001-04 Massachusetts Institute of Technology Copyright (c) 2001-04 Massachusetts Institute of Technology
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
@ -30,6 +30,7 @@ import javax.swing.*;
import javax.swing.text.*; import javax.swing.text.*;
import java.util.*; import java.util.*;
/** /**
* Message console that sits below the editing area. * Message console that sits below the editing area.
* <P> * <P>
@ -48,15 +49,18 @@ public class EditorConsole extends JScrollPane {
boolean cerror; boolean cerror;
//int maxCharCount;
int maxLineCount; int maxLineCount;
static File errFile; static File errFile;
static File outFile; static File outFile;
static File tempFolder; static File tempFolder;
static PrintStream systemOut; // Single static instance shared because there's only one real System.out.
static PrintStream systemErr; // Within the input handlers, the currentConsole variable will be used to
// echo things to the correct location.
static public PrintStream systemOut;
static public PrintStream systemErr;
static PrintStream consoleOut; static PrintStream consoleOut;
static PrintStream consoleErr; static PrintStream consoleErr;
@ -64,6 +68,8 @@ public class EditorConsole extends JScrollPane {
static OutputStream stdoutFile; static OutputStream stdoutFile;
static OutputStream stderrFile; static OutputStream stderrFile;
static EditorConsole currentConsole;
public EditorConsole(Editor editor) { public EditorConsole(Editor editor) {
this.editor = editor; this.editor = editor;
@ -80,10 +86,10 @@ public class EditorConsole extends JScrollPane {
consoleDoc.setParagraphAttributes(0, 0, standard, true); consoleDoc.setParagraphAttributes(0, 0, standard, true);
// build styles for different types of console output // build styles for different types of console output
Color bgColor = Preferences.getColor("console.color"); Color bgColor = Theme.getColor("console.color");
Color fgColorOut = Preferences.getColor("console.output.color"); Color fgColorOut = Theme.getColor("console.output.color");
Color fgColorErr = Preferences.getColor("console.error.color"); Color fgColorErr = Theme.getColor("console.error.color");
Font font = Preferences.getFont("console.font"); Font font = Theme.getFont("console.font");
stdStyle = new SimpleAttributeSet(); stdStyle = new SimpleAttributeSet();
StyleConstants.setForeground(stdStyle, fgColorOut); StyleConstants.setForeground(stdStyle, fgColorOut);
@ -119,32 +125,32 @@ public class EditorConsole extends JScrollPane {
systemOut = System.out; systemOut = System.out;
systemErr = System.err; systemErr = System.err;
// Create a temporary folder which will have a randomized name. Has to
// be randomized otherwise another instance of Processing (or one of its
// sister IDEs) might collide with the file causing permissions problems.
// The files and folders are not deleted on exit because they may be
// needed for debugging or bug reporting.
tempFolder = Base.createTempFolder("console"); tempFolder = Base.createTempFolder("console");
try { try {
String outFileName = Preferences.get("console.output.file"); String outFileName = Preferences.get("console.output.file");
if (outFileName != null) { if (outFileName != null) {
outFile = new File(tempFolder, outFileName); outFile = new File(tempFolder, outFileName);
stdoutFile = new FileOutputStream(outFile); stdoutFile = new FileOutputStream(outFile);
//outFile.deleteOnExit();
} }
String errFileName = Preferences.get("console.error.file"); String errFileName = Preferences.get("console.error.file");
if (errFileName != null) { if (errFileName != null) {
errFile = new File(tempFolder, errFileName); errFile = new File(tempFolder, errFileName);
stderrFile = new FileOutputStream(errFile); stderrFile = new FileOutputStream(errFile);
//errFile.deleteOnExit();
} }
} catch (IOException e) { } catch (IOException e) {
Base.showWarning("Console Error", Base.showWarning("Console Error",
"A problem occurred while trying to open the\n" + "A problem occurred while trying to open the\n" +
"files used to store the console output.", e); "files used to store the console output.", e);
} }
consoleOut = new PrintStream(new EditorConsoleStream(false));
consoleOut = consoleErr = new PrintStream(new EditorConsoleStream(true));
new PrintStream(new EditorConsoleStream(this, false, stdoutFile));
consoleErr =
new PrintStream(new EditorConsoleStream(this, true, stderrFile));
if (Preferences.getBoolean("console")) { if (Preferences.getBoolean("console")) {
try { try {
System.setOut(consoleOut); System.setOut(consoleOut);
@ -176,6 +182,11 @@ public class EditorConsole extends JScrollPane {
}).start(); }).start();
} }
static public void setEditor(Editor editor) {
currentConsole = editor.console;
}
/** /**
* Close the streams so that the temporary files can be deleted. * Close the streams so that the temporary files can be deleted.
@ -229,8 +240,10 @@ public class EditorConsole extends JScrollPane {
synchronized public void message(String what, boolean err, boolean advance) { synchronized public void message(String what, boolean err, boolean advance) {
if (err) { if (err) {
systemErr.print(what); systemErr.print(what);
//systemErr.print("CE" + what);
} else { } else {
systemOut.print(what); systemOut.print(what);
//systemOut.print("CO" + what);
} }
if (advance) { if (advance) {
@ -242,14 +255,14 @@ public class EditorConsole extends JScrollPane {
} }
} }
// to console display // to console display
appendText(what, err); appendText(what, err);
// moved down here since something is punting // moved down here since something is punting
} }
/** /**
* append a piece of text to the console. * Append a piece of text to the console.
* <P> * <P>
* Swing components are NOT thread-safe, and since the MessageSiphon * Swing components are NOT thread-safe, and since the MessageSiphon
* instantiates new threads, and in those callbacks, they often print * instantiates new threads, and in those callbacks, they often print
@ -264,6 +277,7 @@ public class EditorConsole extends JScrollPane {
consoleDoc.appendString(txt, e ? errStyle : stdStyle); consoleDoc.appendString(txt, e ? errStyle : stdStyle);
} }
public void clear() { public void clear() {
try { try {
consoleDoc.remove(0, consoleDoc.getLength()); consoleDoc.remove(0, consoleDoc.getLength());
@ -272,68 +286,96 @@ public class EditorConsole extends JScrollPane {
// maybe not a good idea in the long run? // maybe not a good idea in the long run?
} }
} }
}
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
class EditorConsoleStream extends OutputStream {
//static EditorConsole current;
boolean err; // whether stderr or stdout
byte single[] = new byte[1];
public EditorConsoleStream(boolean err) {
this.err = err;
}
class EditorConsoleStream extends OutputStream { public void close() { }
EditorConsole parent;
boolean err; // whether stderr or stdout
byte single[] = new byte[1];
OutputStream echo;
public EditorConsoleStream(EditorConsole parent, public void flush() { }
boolean err, OutputStream echo) {
this.parent = parent;
this.err = err;
this.echo = echo;
}
public void close() { } public void write(byte b[]) { // appears never to be used
// if (currentConsole.isDisplayable()) {
currentConsole.write(b, 0, b.length, err);
// } else {
// systemOut.println("not displayable");
// if (err) {
// systemErr.write(b, 0, b.length);
// } else {
// systemOut.write(b, 0, b.length);
// }
// }
public void flush() { } OutputStream echo = err ? stderrFile : stdoutFile;
if (echo != null) {
public void write(byte b[]) { // appears never to be used try {
parent.write(b, 0, b.length, err); echo.write(b);
if (echo != null) { echo.flush();
try { } catch (IOException e) {
echo.write(b); //, 0, b.length); e.printStackTrace();
echo.flush(); echo = null;
} catch (IOException e) { }
e.printStackTrace();
echo = null;
} }
} }
}
public void write(byte b[], int offset, int length) { public void write(byte b[], int offset, int length) {
parent.write(b, offset, length, err); currentConsole.write(b, offset, length, err);
if (echo != null) { // if (currentConsole.isDisplayable()) {
try { // systemOut.println("is displayable");
echo.write(b, offset, length); // currentConsole.write(b, offset, length, err);
echo.flush(); // } else {
} catch (IOException e) { // systemOut.println("not displayable");
e.printStackTrace(); // if (err) {
echo = null; // systemErr.write(b, offset, length);
// } else {
// systemOut.write(b, offset, length);
// }
// }
OutputStream echo = err ? stderrFile : stdoutFile;
if (echo != null) {
try {
echo.write(b, offset, length);
echo.flush();
} catch (IOException e) {
e.printStackTrace();
echo = null;
}
} }
} }
}
public void write(int b) { public void write(int b) {
single[0] = (byte)b; single[0] = (byte)b;
parent.write(single, 0, 1, err); currentConsole.write(single, 0, 1, err);
if (echo != null) {
try { OutputStream echo = err ? stderrFile : stdoutFile;
echo.write(b); if (echo != null) {
echo.flush(); try {
} catch (IOException e) { echo.write(b);
e.printStackTrace(); echo.flush();
echo = null; } catch (IOException e) {
e.printStackTrace();
echo = null;
}
} }
} }
} }
} }
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
/** /**
* Buffer updates to the console and output them in batches. For info, see: * Buffer updates to the console and output them in batches. For info, see:
* http://java.sun.com/products/jfc/tsc/articles/text/element_buffer and * http://java.sun.com/products/jfc/tsc/articles/text/element_buffer and

View File

@ -1,9 +1,9 @@
/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ /* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/* /*
Part of the Processing project - http://processing.org Part of the Processing project - http://processing.org
Copyright (c) 2004-05 Ben Fry and Casey Reas Copyright (c) 2004-08 Ben Fry and Casey Reas
Copyright (c) 2001-04 Massachusetts Institute of Technology Copyright (c) 2001-04 Massachusetts Institute of Technology
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
@ -25,10 +25,8 @@ package processing.app;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import java.io.*;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.*;
/** /**
@ -50,8 +48,6 @@ public class EditorHeader extends JComponent {
JMenu menu; JMenu menu;
JPopupMenu popup; JPopupMenu popup;
JMenuItem hideItem;
int menuLeft; int menuLeft;
int menuRight; int menuRight;
@ -69,7 +65,7 @@ public class EditorHeader extends JComponent {
static final int PIECE_WIDTH = 4; static final int PIECE_WIDTH = 4;
Image[][] pieces; static Image[][] pieces;
// //
@ -81,24 +77,23 @@ public class EditorHeader extends JComponent {
public EditorHeader(Editor eddie) { public EditorHeader(Editor eddie) {
this.editor = eddie; // weird name for listener this.editor = eddie; // weird name for listener
pieces = new Image[STATUS.length][WHERE.length]; if (pieces == null) {
for (int i = 0; i < STATUS.length; i++) { pieces = new Image[STATUS.length][WHERE.length];
for (int j = 0; j < WHERE.length; j++) { for (int i = 0; i < STATUS.length; i++) {
pieces[i][j] = Base.getImage("tab-" + STATUS[i] + "-" + for (int j = 0; j < WHERE.length; j++) {
WHERE[j] + ".gif", this); String path = "tab-" + STATUS[i] + "-" + WHERE[j] + ".gif";
pieces[i][j] = Base.getThemeImage(path, this);
}
} }
} }
if (backgroundColor == null) { if (backgroundColor == null) {
//backgroundColor = backgroundColor =
//Preferences.getColor("header.bgcolor"); Theme.getColor("header.bgcolor");
// hardcoding new blue color scheme for consistency with images,
// see EditorStatus.java for details.
backgroundColor = new Color(0x21, 0x68, 0x86);
textColor[SELECTED] = textColor[SELECTED] =
Preferences.getColor("header.text.selected.color"); Theme.getColor("header.text.selected.color");
textColor[UNSELECTED] = textColor[UNSELECTED] =
Preferences.getColor("header.text.unselected.color"); Theme.getColor("header.text.unselected.color");
} }
addMouseListener(new MouseAdapter() { addMouseListener(new MouseAdapter() {
@ -110,9 +105,10 @@ public class EditorHeader extends JComponent {
popup.show(EditorHeader.this, x, y); popup.show(EditorHeader.this, x, y);
} else { } else {
for (int i = 0; i < editor.sketch.codeCount; i++) { Sketch sketch = editor.getSketch();
for (int i = 0; i < sketch.getCodeCount(); i++) {
if ((x > tabLeft[i]) && (x < tabRight[i])) { if ((x > tabLeft[i]) && (x < tabRight[i])) {
editor.sketch.setCurrent(i); sketch.setCurrentCode(i);
repaint(); repaint();
} }
} }
@ -125,7 +121,7 @@ public class EditorHeader extends JComponent {
public void paintComponent(Graphics screen) { public void paintComponent(Graphics screen) {
if (screen == null) return; if (screen == null) return;
Sketch sketch = editor.sketch; Sketch sketch = editor.getSketch();
if (sketch == null) return; // ?? if (sketch == null) return; // ??
Dimension size = getSize(); Dimension size = getSize();
@ -140,7 +136,6 @@ public class EditorHeader extends JComponent {
// who cares, just resize // who cares, just resize
sizeW = size.width; sizeW = size.width;
sizeH = size.height; sizeH = size.height;
//userLeft = 0; // reset
} }
} }
@ -154,7 +149,7 @@ public class EditorHeader extends JComponent {
Graphics g = offscreen.getGraphics(); Graphics g = offscreen.getGraphics();
if (font == null) { if (font == null) {
font = Preferences.getFont("header.text.font"); font = Theme.getFont("header.text.font");
} }
g.setFont(font); // need to set this each time through g.setFont(font); // need to set this each time through
metrics = g.getFontMetrics(); metrics = g.getFontMetrics();
@ -169,28 +164,22 @@ public class EditorHeader extends JComponent {
g.setColor(backgroundColor); g.setColor(backgroundColor);
g.fillRect(0, 0, imageW, imageH); g.fillRect(0, 0, imageW, imageH);
if ((tabLeft == null) || int codeCount = sketch.getCodeCount();
(tabLeft.length < sketch.codeCount)) { if ((tabLeft == null) || (tabLeft.length < codeCount)) {
tabLeft = new int[sketch.codeCount]; tabLeft = new int[codeCount];
tabRight = new int[sketch.codeCount]; tabRight = new int[codeCount];
} }
// disable hide on the first tab
hideItem.setEnabled(sketch.current != sketch.code[0]);
//int x = 0; //Preferences.GUI_SMALL;
//int x = (Base.platform == Base.MACOSX) ? 0 : 1;
int x = 6; // offset from left edge of the component int x = 6; // offset from left edge of the component
for (int i = 0; i < sketch.codeCount; i++) { for (int i = 0; i < sketch.getCodeCount(); i++) {
SketchCode code = sketch.code[i]; SketchCode code = sketch.getCode(i);
String codeName = (code.flavor == Sketch.PDE) ? String codeName = sketch.hideExtension(code.getExtension()) ?
code.name : code.file.getName(); code.getPrettyName() : code.getFileName();
// if modified, add the li'l glyph next to the name // if modified, add the li'l glyph next to the name
String text = " " + codeName + (code.modified ? " \u00A7" : " "); String text = " " + codeName + (code.isModified() ? " \u00A7" : " ");
//int textWidth = metrics.stringWidth(text);
Graphics2D g2 = (Graphics2D) g; Graphics2D g2 = (Graphics2D) g;
int textWidth = (int) int textWidth = (int)
font.getStringBounds(text, g2.getFontRenderContext()).getWidth(); font.getStringBounds(text, g2.getFontRenderContext()).getWidth();
@ -198,7 +187,7 @@ public class EditorHeader extends JComponent {
int pieceCount = 2 + (textWidth / PIECE_WIDTH); int pieceCount = 2 + (textWidth / PIECE_WIDTH);
int pieceWidth = pieceCount * PIECE_WIDTH; int pieceWidth = pieceCount * PIECE_WIDTH;
int state = (code == sketch.current) ? SELECTED : UNSELECTED; int state = (code == sketch.getCurrentCode()) ? SELECTED : UNSELECTED;
g.drawImage(pieces[state][LEFT], x, 0, null); g.drawImage(pieces[state][LEFT], x, 0, null);
x += PIECE_WIDTH; x += PIECE_WIDTH;
@ -237,6 +226,7 @@ public class EditorHeader extends JComponent {
//System.out.println("rebuilding editor header"); //System.out.println("rebuilding editor header");
rebuildMenu(); rebuildMenu();
repaint(); repaint();
Toolkit.getDefaultToolkit().sync();
} }
@ -297,10 +287,11 @@ public class EditorHeader extends JComponent {
menu.addSeparator(); menu.addSeparator();
*/ */
item = new JMenuItem("New Tab"); //item = new JMenuItem("New Tab");
item = Editor.newJMenuItemShift("New Tab", 'N');
item.addActionListener(new ActionListener() { item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
editor.sketch.newCode(); editor.getSketch().handleNewCode();
} }
}); });
menu.add(item); menu.add(item);
@ -308,10 +299,13 @@ public class EditorHeader extends JComponent {
item = new JMenuItem("Rename"); item = new JMenuItem("Rename");
item.addActionListener(new ActionListener() { item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
editor.sketch.renameCode(); editor.getSketch().handleRenameCode();
/*
// this is already being called by nameCode(), the second stage of rename
if (editor.sketch.current == editor.sketch.code[0]) { if (editor.sketch.current == editor.sketch.code[0]) {
editor.sketchbook.rebuildMenus(); editor.sketchbook.rebuildMenus();
} }
*/
} }
}); });
menu.add(item); menu.add(item);
@ -319,59 +313,19 @@ public class EditorHeader extends JComponent {
item = new JMenuItem("Delete"); item = new JMenuItem("Delete");
item.addActionListener(new ActionListener() { item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
editor.sketch.deleteCode(); editor.getSketch().handleDeleteCode();
} }
}); });
menu.add(item); menu.add(item);
item = new JMenuItem("Hide");
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
editor.sketch.hideCode();
}
});
menu.add(item);
hideItem = item;
JMenu unhide = new JMenu("Unhide");
ActionListener unhideListener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
String which = (String) e.getActionCommand();
editor.sketch.unhideCode(which);
rebuildMenu();
}
};
Sketch sketch = editor.sketch;
if (sketch != null) {
for (int i = 0; i < sketch.hiddenCount; i++) {
item = new JMenuItem(sketch.hidden[i].name +
Sketch.flavorExtensionsShown[sketch.hidden[i].flavor]);
item.setActionCommand(sketch.hidden[i].name +
Sketch.flavorExtensionsShown[sketch.hidden[i].flavor]);
item.addActionListener(unhideListener);
unhide.add(item);
}
}
if (unhide.getItemCount() == 0) {
unhide.setEnabled(false);
}
menu.add(unhide);
menu.addSeparator(); menu.addSeparator();
// KeyEvent.VK_LEFT and VK_RIGHT will make Windows beep // KeyEvent.VK_LEFT and VK_RIGHT will make Windows beep
int ctrlAlt = ActionEvent.ALT_MASK |
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
//item = Editor.newJMenuItem("Previous Tab", '[', true);
item = new JMenuItem("Previous Tab"); item = new JMenuItem("Previous Tab");
//int shortcut = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); KeyStroke ctrlAltLeft =
KeyStroke ctrlAltLeft = KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, ctrlAlt); KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, Editor.SHORTCUT_ALT_KEY_MASK);
item.setAccelerator(ctrlAltLeft); item.setAccelerator(ctrlAltLeft);
//int modifiers = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
//KeyStroke tabby = KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, modifiers);
// this didn't want to work consistently // this didn't want to work consistently
/* /*
item.addActionListener(new ActionListener() { item.addActionListener(new ActionListener() {
@ -382,9 +336,9 @@ public class EditorHeader extends JComponent {
*/ */
menu.add(item); menu.add(item);
//item = Editor.newJMenuItem("Next Tab", ']', true);
item = new JMenuItem("Next Tab"); item = new JMenuItem("Next Tab");
KeyStroke ctrlAltRight = KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, ctrlAlt); KeyStroke ctrlAltRight =
KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, Editor.SHORTCUT_ALT_KEY_MASK);
item.setAccelerator(ctrlAltRight); item.setAccelerator(ctrlAltRight);
/* /*
item.addActionListener(new ActionListener() { item.addActionListener(new ActionListener() {
@ -395,17 +349,17 @@ public class EditorHeader extends JComponent {
*/ */
menu.add(item); menu.add(item);
Sketch sketch = editor.getSketch();
if (sketch != null) { if (sketch != null) {
menu.addSeparator(); menu.addSeparator();
ActionListener jumpListener = new ActionListener() { ActionListener jumpListener = new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
editor.sketch.setCurrent(e.getActionCommand()); editor.getSketch().setCurrentCode(e.getActionCommand());
} }
}; };
for (int i = 0; i < sketch.codeCount; i++) { for (SketchCode code : sketch.getCode()) {
item = new JMenuItem(sketch.code[i].name + item = new JMenuItem(code.getPrettyName());
Sketch.flavorExtensionsShown[sketch.code[i].flavor]);
item.addActionListener(jumpListener); item.addActionListener(jumpListener);
menu.add(item); menu.add(item);
} }
@ -417,10 +371,12 @@ public class EditorHeader extends JComponent {
repaint(); repaint();
} }
public Dimension getPreferredSize() { public Dimension getPreferredSize() {
return getMinimumSize(); return getMinimumSize();
} }
public Dimension getMinimumSize() { public Dimension getMinimumSize() {
if (Base.isMacOS()) { if (Base.isMacOS()) {
return new Dimension(300, Preferences.GRID_SIZE); return new Dimension(300, Preferences.GRID_SIZE);
@ -428,6 +384,7 @@ public class EditorHeader extends JComponent {
return new Dimension(300, Preferences.GRID_SIZE - 1); return new Dimension(300, Preferences.GRID_SIZE - 1);
} }
public Dimension getMaximumSize() { public Dimension getMaximumSize() {
if (Base.isMacOS()) { if (Base.isMacOS()) {
return new Dimension(3000, Preferences.GRID_SIZE); return new Dimension(3000, Preferences.GRID_SIZE);

View File

@ -1,9 +1,9 @@
/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ /* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/* /*
Part of the Processing project - http://processing.org Part of the Processing project - http://processing.org
Copyright (c) 2005 Ben Fry and Casey Reas Copyright (c) 2005-07 Ben Fry and Casey Reas
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -25,10 +25,7 @@ package processing.app;
import processing.app.syntax.*; import processing.app.syntax.*;
import java.awt.*; import java.awt.*;
import java.awt.event.*;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.*;
/** /**
@ -52,16 +49,13 @@ public class EditorLineStatus extends JComponent {
this.textarea = textarea; this.textarea = textarea;
textarea.editorLineStatus = this; textarea.editorLineStatus = this;
// hardcoding new blue color scheme for consistency with images, background = Theme.getColor("linestatus.bgcolor");
// see EditorStatus.java for details. font = Theme.getFont("linestatus.font");
//background = Preferences.getColor("linestatus.bgcolor"); foreground = Theme.getColor("linestatus.color");
background = new Color(0x04, 0x4F, 0x6F); high = Theme.getInteger("linestatus.height");
font = Preferences.getFont("linestatus.font");
foreground = Preferences.getColor("linestatus.color");
high = Preferences.getInteger("linestatus.height");
if (Base.isMacOS()) { if (Base.isMacOS()) {
resize = Base.getImage("resize.gif", this); resize = Base.getThemeImage("resize.gif", this);
} }
//linestatus.bgcolor = #000000 //linestatus.bgcolor = #000000
//linestatus.font = SansSerif,plain,10 //linestatus.font = SansSerif,plain,10

View File

@ -1,9 +1,9 @@
/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ /* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/* /*
Part of the Processing project - http://processing.org Part of the Processing project - http://processing.org
Copyright (c) 2004-05 Ben Fry and Casey Reas Copyright (c) 2004-08 Ben Fry and Casey Reas
Copyright (c) 2001-04 Massachusetts Institute of Technology Copyright (c) 2001-04 Massachusetts Institute of Technology
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
@ -28,10 +28,6 @@ import processing.app.syntax.*;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import javax.swing.*;
import javax.swing.text.*;
import javax.swing.event.*;
/** /**
* Filters key events for tab expansion/indent/etc. * Filters key events for tab expansion/indent/etc.
@ -47,18 +43,18 @@ import javax.swing.event.*;
* smarter parser/formatter, rather than continuing to hack this class. * smarter parser/formatter, rather than continuing to hack this class.
*/ */
public class EditorListener { public class EditorListener {
Editor editor; private Editor editor;
JEditTextArea textarea; private JEditTextArea textarea;
boolean externalEditor; private boolean externalEditor;
boolean tabsExpand; private boolean tabsExpand;
boolean tabsIndent; private boolean tabsIndent;
int tabSize; private int tabSize;
String tabString; private String tabString;
boolean autoIndent; private boolean autoIndent;
int selectionStart, selectionEnd; // private int selectionStart, selectionEnd;
int position; // private int position;
/** ctrl-alt on windows and linux, cmd-alt on mac os x */ /** ctrl-alt on windows and linux, cmd-alt on mac os x */
static final int CTRL_ALT = ActionEvent.ALT_MASK | static final int CTRL_ALT = ActionEvent.ALT_MASK |
@ -97,6 +93,7 @@ public class EditorListener {
* Called by JEditTextArea inside processKeyEvent(). Note that this * Called by JEditTextArea inside processKeyEvent(). Note that this
* won't intercept actual characters, because those are fired on * won't intercept actual characters, because those are fired on
* keyTyped(). * keyTyped().
* @return true if the event has been handled (to remove it from the queue)
*/ */
public boolean keyPressed(KeyEvent event) { public boolean keyPressed(KeyEvent event) {
// don't do things if the textarea isn't editable // don't do things if the textarea isn't editable
@ -106,15 +103,17 @@ public class EditorListener {
char c = event.getKeyChar(); char c = event.getKeyChar();
int code = event.getKeyCode(); int code = event.getKeyCode();
//System.out.println(c + " " + code + " " + event); //System.out.println((int)c + " " + code + " " + event);
//System.out.println(); //System.out.println();
Sketch sketch = editor.getSketch();
if ((event.getModifiers() & CTRL_ALT) == CTRL_ALT) { if ((event.getModifiers() & CTRL_ALT) == CTRL_ALT) {
if (code == KeyEvent.VK_LEFT) { if (code == KeyEvent.VK_LEFT) {
editor.sketch.prevCode(); sketch.handlePrevCode();
return true; return true;
} else if (code == KeyEvent.VK_RIGHT) { } else if (code == KeyEvent.VK_RIGHT) {
editor.sketch.nextCode(); sketch.handleNextCode();
return true; return true;
} }
} }
@ -125,10 +124,10 @@ public class EditorListener {
} }
// TODO i don't like these accessors. clean em up later. // TODO i don't like these accessors. clean em up later.
if (!editor.sketch.modified) { if (!editor.getSketch().isModified()) {
if ((code == KeyEvent.VK_BACK_SPACE) || (code == KeyEvent.VK_TAB) || if ((code == KeyEvent.VK_BACK_SPACE) || (code == KeyEvent.VK_TAB) ||
(code == KeyEvent.VK_ENTER) || ((c >= 32) && (c < 128))) { (code == KeyEvent.VK_ENTER) || ((c >= 32) && (c < 128))) {
editor.sketch.setModified(true); sketch.setModified(true);
} }
} }
@ -209,8 +208,12 @@ public class EditorListener {
switch ((int) c) { switch ((int) c) {
case 9: case 9: // TAB
if (tabsExpand) { // expand tabs if (textarea.isSelectionActive()) {
boolean outdent = (event.getModifiers() & KeyEvent.SHIFT_MASK) != 0;
editor.handleIndentOutdent(!outdent);
} else if (tabsExpand) { // expand tabs
textarea.setSelectedText(tabString); textarea.setSelectedText(tabString);
event.consume(); event.consume();
return true; return true;
@ -371,11 +374,11 @@ public class EditorListener {
if (spaceCount < 0) { if (spaceCount < 0) {
// for rev 0122, actually delete extra space // for rev 0122, actually delete extra space
//textarea.setSelectionStart(origIndex + 1); //textarea.setSelectionStart(origIndex + 1);
textarea.setSelectionEnd(textarea.getSelectionEnd() - spaceCount); textarea.setSelectionEnd(textarea.getSelectionStop() - spaceCount);
textarea.setSelectedText("\n"); textarea.setSelectedText("\n");
} else { } else {
String insertion = "\n" + Editor.EMPTY.substring(0, spaceCount); String insertion = "\n" + Editor.EMPTY.substring(0, spaceCount);
textarea.setSelectedText(insertion); textarea.setSelectedText(insertion);
} }
// not gonna bother handling more than one brace // not gonna bother handling more than one brace
@ -394,19 +397,22 @@ public class EditorListener {
} }
} }
} }
} else {
// mark this event as already handled // Enter/Return was being consumed by somehow even if false
event.consume(); // was returned, so this is a band-aid to simply fire the event again.
return true; // http://dev.processing.org/bugs/show_bug.cgi?id=1073
textarea.setSelectedText(String.valueOf(c));
} }
break; // mark this event as already handled (all but ignored)
event.consume();
return true;
case '}': case '}':
if (autoIndent) { if (autoIndent) {
// first remove anything that was there (in case this multiple // first remove anything that was there (in case this multiple
// characters are selected, so that it's not in the way of the // characters are selected, so that it's not in the way of the
// spaces for the auto-indent // spaces for the auto-indent
if (textarea.getSelectionStart() != textarea.getSelectionEnd()) { if (textarea.getSelectionStart() != textarea.getSelectionStop()) {
textarea.setSelectedText(""); textarea.setSelectedText("");
} }
@ -435,59 +441,9 @@ public class EditorListener {
if (!finished) return false; // brace with no start if (!finished) return false; // brace with no start
int lineStartIndex = index; int lineStartIndex = index;
/*
// now that we know things are ok to be indented, walk
// backwards to the last { to see how far its line is indented.
// this isn't perfect cuz it'll pick up commented areas,
// but that's not really a big deal and can be fixed when
// this is all given a more complete (proper) solution.
index = prevCharIndex;
int braceDepth = 1;
finished = false;
while ((index != -1) && (!finished)) {
if (contents[index] == '}') {
// aww crap, this means we're one deeper
// and will have to find one more extra {
braceDepth++;
index--;
} else if (contents[index] == '{') {
braceDepth--;
if (braceDepth == 0) {
finished = true;
} // otherwise just teasing, keep going..
} else {
index--;
}
}
// never found a proper brace, be safe and don't do anything
if (!finished) return false;
// check how many spaces on the line with the matching open brace
int pairedSpaceCount = calcSpaceCount(index, contents);
//System.out.println(pairedSpaceCount);
*/
int pairedSpaceCount = calcBraceIndent(prevCharIndex, contents); //, 1); int pairedSpaceCount = calcBraceIndent(prevCharIndex, contents); //, 1);
if (pairedSpaceCount == -1) return false; if (pairedSpaceCount == -1) return false;
/*
// now walk forward and figure out how many spaces there are
while ((index < contents.length) && (index >= 0) &&
(contents[index++] == ' ')) {
spaceCount++;
}
*/
// number of spaces found on this line
//int newSpaceCount = Math.max(0, spaceCount - tabSize);
// number of spaces on this current line
//int spaceCount = calcSpaces(caretIndex, contents);
//System.out.println("spaces is " + spaceCount);
//String insertion = "\n" + Editor.EMPTY.substring(0, spaceCount);
//int differential = newSpaceCount - spaceCount;
//System.out.println("diff is " + differential);
//int newStart = textarea.getSelectionStart() + differential;
//textarea.setSelectionStart(newStart);
//textarea.setSelectedText("}");
textarea.setSelectionStart(lineStartIndex); textarea.setSelectionStart(lineStartIndex);
textarea.setSelectedText(Editor.EMPTY.substring(0, pairedSpaceCount)); textarea.setSelectedText(Editor.EMPTY.substring(0, pairedSpaceCount));
@ -501,32 +457,19 @@ public class EditorListener {
} }
/** Cmd-Shift or Ctrl-Shift depending on the platform */
//static final int CMD_SHIFT = ActionEvent.SHIFT_MASK |
// Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
/** ctrl-alt on windows and linux, cmd-alt on mac os x */
//static final int CTRL_ALT = ActionEvent.ALT_MASK |
// Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
/*
public boolean keyTyped(KeyEvent event) { public boolean keyTyped(KeyEvent event) {
char c = event.getKeyChar(); char c = event.getKeyChar();
int code = event.getKeyCode();
if ((event.getModifiers() & CMD_ALT) == CMD_ALT) { if ((event.getModifiers() & KeyEvent.CTRL_MASK) != 0) {
if (code == KeyEvent.VK_LEFT) { // on linux, ctrl-comma (prefs) being passed through to the editor
//if (c == '[') { if (c == KeyEvent.VK_COMMA) {
editor.sketch.prevCode(); event.consume();
return true;
} else if (code == KeyEvent.VK_RIGHT) {
//} else if (c == ']') {
editor.sketch.nextCode();
return true; return true;
} }
} }
return false; return false;
} }
*/
/** /**
@ -535,7 +478,7 @@ public class EditorListener {
protected int calcLineStart(int index, char contents[]) { protected int calcLineStart(int index, char contents[]) {
// backup from the current caret position to the last newline, // backup from the current caret position to the last newline,
// so that we can figure out how far this line was indented // so that we can figure out how far this line was indented
int spaceCount = 0; /*int spaceCount = 0;*/
boolean finished = false; boolean finished = false;
while ((index != -1) && (!finished)) { while ((index != -1) && (!finished)) {
if ((contents[index] == 10) || if ((contents[index] == 10) ||

View File

@ -0,0 +1,431 @@
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
Part of the Processing project - http://processing.org
Copyright (c) 2004-08 Ben Fry and Casey Reas
Copyright (c) 2001-04 Massachusetts Institute of Technology
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package processing.app;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/**
* Panel just below the editing area that contains status messages.
*/
public class EditorStatus extends JPanel /*implements ActionListener*/ {
static Color bgcolor[];
static Color fgcolor[];
static final int NOTICE = 0;
static final int ERR = 1;
//static final int PROMPT = 2;
//static final int EDIT = 3;
static final int EDIT = 2;
static final int YES = 1;
static final int NO = 2;
static final int CANCEL = 3;
static final int OK = 4;
static final String NO_MESSAGE = "";
Editor editor;
int mode;
String message;
Font font;
FontMetrics metrics;
int ascent;
Image offscreen;
int sizeW, sizeH;
int imageW, imageH;
//JButton yesButton;
//JButton noButton;
JButton cancelButton;
JButton okButton;
JTextField editField;
//Thread promptThread;
int response;
public EditorStatus(Editor editor) {
this.editor = editor;
empty();
if (bgcolor == null) {
bgcolor = new Color[3]; //4];
bgcolor[0] = Theme.getColor("status.notice.bgcolor");
bgcolor[1] = Theme.getColor("status.error.bgcolor");
bgcolor[2] = Theme.getColor("status.edit.bgcolor");
fgcolor = new Color[3]; //4];
fgcolor[0] = Theme.getColor("status.notice.fgcolor");
fgcolor[1] = Theme.getColor("status.error.fgcolor");
fgcolor[2] = Theme.getColor("status.edit.fgcolor");
}
}
public void empty() {
mode = NOTICE;
message = NO_MESSAGE;
//update();
repaint();
}
public void notice(String message) {
mode = NOTICE;
this.message = message;
//update();
repaint();
}
public void unnotice(String unmessage) {
if (message.equals(unmessage)) empty();
}
public void error(String message) {
mode = ERR;
this.message = message;
repaint();
}
/*
public void prompt(String message) {
mode = PROMPT;
this.message = message;
response = 0;
yesButton.setVisible(true);
noButton.setVisible(true);
cancelButton.setVisible(true);
yesButton.requestFocus();
repaint();
}
// prompt has been handled, re-hide the buttons
public void unprompt() {
yesButton.setVisible(false);
noButton.setVisible(false);
cancelButton.setVisible(false);
empty();
}
*/
public void edit(String message, String dflt) {
mode = EDIT;
this.message = message;
response = 0;
okButton.setVisible(true);
cancelButton.setVisible(true);
editField.setVisible(true);
editField.setText(dflt);
editField.selectAll();
editField.requestFocus();
repaint();
}
public void unedit() {
okButton.setVisible(false);
cancelButton.setVisible(false);
editField.setVisible(false);
empty();
}
/*
public void update() {
Graphics g = this.getGraphics();
try {
setBackground(bgcolor[mode]);
} catch (NullPointerException e) { } // if not ready yet
if (g != null) paint(g);
}
public void update(Graphics g) {
paint(g);
}
*/
public void paintComponent(Graphics screen) {
//if (screen == null) return;
if (okButton == null) setup();
//System.out.println("status.paintComponent");
Dimension size = getSize();
if ((size.width != sizeW) || (size.height != sizeH)) {
// component has been resized
if ((size.width > imageW) || (size.height > imageH)) {
// nix the image and recreate, it's too small
offscreen = null;
} else {
// who cares, just resize
sizeW = size.width;
sizeH = size.height;
setButtonBounds();
}
}
if (offscreen == null) {
sizeW = size.width;
sizeH = size.height;
setButtonBounds();
imageW = sizeW;
imageH = sizeH;
offscreen = createImage(imageW, imageH);
}
Graphics g = offscreen.getGraphics();
if (font == null) {
font = Theme.getFont("status.font");
//new Font("SansSerif", Font.PLAIN, 12));
g.setFont(font);
metrics = g.getFontMetrics();
ascent = metrics.getAscent();
}
//setBackground(bgcolor[mode]); // does nothing
g.setColor(bgcolor[mode]);
g.fillRect(0, 0, imageW, imageH);
g.setColor(fgcolor[mode]);
g.setFont(font); // needs to be set each time on osx
g.drawString(message, Preferences.GUI_SMALL, (sizeH + ascent) / 2);
screen.drawImage(offscreen, 0, 0, null);
}
protected void setup() {
if (okButton == null) {
cancelButton = new JButton(Preferences.PROMPT_CANCEL);
okButton = new JButton(Preferences.PROMPT_OK);
cancelButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (mode == EDIT) {
unedit();
//editor.toolbar.clear();
}
}
});
okButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// answering to rename/new code question
if (mode == EDIT) { // this if() isn't (shouldn't be?) necessary
String answer = editField.getText();
editor.getSketch().nameCode(answer);
unedit();
}
}
});
// !@#(* aqua ui #($*(( that turtle-neck wearing #(** (#$@)(
// os9 seems to work if bg of component is set, but x still a bastard
if (Base.isMacOS()) {
//yesButton.setBackground(bgcolor[EDIT]);
//noButton.setBackground(bgcolor[EDIT]);
cancelButton.setBackground(bgcolor[EDIT]);
okButton.setBackground(bgcolor[EDIT]);
}
setLayout(null);
/*
yesButton.addActionListener(this);
noButton.addActionListener(this);
cancelButton.addActionListener(this);
okButton.addActionListener(this);
*/
//add(yesButton);
//add(noButton);
add(cancelButton);
add(okButton);
//yesButton.setVisible(false);
//noButton.setVisible(false);
cancelButton.setVisible(false);
okButton.setVisible(false);
editField = new JTextField();
// disabling, was not in use
//editField.addActionListener(this);
//if (Base.platform != Base.MACOSX) {
editField.addKeyListener(new KeyAdapter() {
// Grab ESC with keyPressed, because it's not making it to keyTyped
public void keyPressed(KeyEvent event) {
if (event.getKeyChar() == KeyEvent.VK_ESCAPE) {
unedit();
//editor.toolbar.clear();
event.consume();
}
}
// use keyTyped to catch when the feller is actually
// added to the text field. with keyTyped, as opposed to
// keyPressed, the keyCode will be zero, even if it's
// enter or backspace or whatever, so the keychar should
// be used instead. grr.
public void keyTyped(KeyEvent event) {
//System.out.println("got event " + event);
int c = event.getKeyChar();
if (c == KeyEvent.VK_ENTER) { // accept the input
String answer = editField.getText();
editor.getSketch().nameCode(answer);
unedit();
event.consume();
// easier to test the affirmative case than the negative
} else if ((c == KeyEvent.VK_BACK_SPACE) ||
(c == KeyEvent.VK_DELETE) ||
(c == KeyEvent.VK_RIGHT) ||
(c == KeyEvent.VK_LEFT) ||
(c == KeyEvent.VK_UP) ||
(c == KeyEvent.VK_DOWN) ||
(c == KeyEvent.VK_HOME) ||
(c == KeyEvent.VK_END) ||
(c == KeyEvent.VK_SHIFT)) {
// these events are ignored
/*
} else if (c == KeyEvent.VK_ESCAPE) {
unedit();
editor.toolbar.clear();
event.consume();
*/
} else if (c == KeyEvent.VK_SPACE) {
String t = editField.getText();
int start = editField.getSelectionStart();
int end = editField.getSelectionEnd();
editField.setText(t.substring(0, start) + "_" +
t.substring(end));
editField.setCaretPosition(start+1);
event.consume();
} else if ((c == '_') || (c == '.') || // allow .pde and .java
((c >= 'A') && (c <= 'Z')) ||
((c >= 'a') && (c <= 'z'))) {
// these are ok, allow them through
} else if ((c >= '0') && (c <= '9')) {
// getCaretPosition == 0 means that it's the first char
// and the field is empty.
// getSelectionStart means that it *will be* the first
// char, because the selection is about to be replaced
// with whatever is typed.
if ((editField.getCaretPosition() == 0) ||
(editField.getSelectionStart() == 0)) {
// number not allowed as first digit
//System.out.println("bad number bad");
event.consume();
}
} else {
event.consume();
//System.out.println("code is " + code + " char = " + c);
}
//System.out.println("code is " + code + " char = " + c);
}
});
add(editField);
editField.setVisible(false);
}
}
protected void setButtonBounds() {
int top = (sizeH - Preferences.BUTTON_HEIGHT) / 2;
int eachButton = Preferences.GUI_SMALL + Preferences.BUTTON_WIDTH;
int cancelLeft = sizeW - eachButton;
int noLeft = cancelLeft - eachButton;
int yesLeft = noLeft - eachButton;
//yesButton.setLocation(yesLeft, top);
//noButton.setLocation(noLeft, top);
cancelButton.setLocation(cancelLeft, top);
okButton.setLocation(noLeft, top);
//yesButton.setSize(Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT);
//noButton.setSize(Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT);
cancelButton.setSize(Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT);
okButton.setSize(Preferences.BUTTON_WIDTH, Preferences.BUTTON_HEIGHT);
// edit field height is awkward, and very different between mac and pc,
// so use at least the preferred height for now.
int editWidth = 2*Preferences.BUTTON_WIDTH;
int editHeight = editField.getPreferredSize().height;
int editTop = (1 + sizeH - editHeight) / 2; // add 1 for ceil
editField.setBounds(yesLeft - Preferences.BUTTON_WIDTH, editTop,
editWidth, editHeight);
}
public Dimension getPreferredSize() {
return getMinimumSize();
}
public Dimension getMinimumSize() {
return new Dimension(300, Preferences.GRID_SIZE);
}
public Dimension getMaximumSize() {
return new Dimension(3000, Preferences.GRID_SIZE);
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == cancelButton) {
if (mode == EDIT) unedit();
//editor.toolbar.clear();
} else if (e.getSource() == okButton) {
// answering to rename/new code question
if (mode == EDIT) { // this if() isn't (shouldn't be?) necessary
String answer = editField.getText();
editor.getSketch().nameCode(answer);
unedit();
}
}
}
}

Some files were not shown because too many files have changed in this diff Show More