App-Asciio
view release on metacpan or search on metacpan
lib/App/Asciio.pm view on Meta::CPAN
It has always been painful to do ASCII diagrams by hand. This perl application allows
you to draw ASCII diagrams in a modern (but simple) graphical interface.
The ASCII graphs can be saved as ASCII or in a format that allows you to modify them later.
Special thanks go to the Muppet and the gtk-perl group, Gábor Szabó for his help and advices.
Adam Kennedy coined the cool name.
=head1 DOCUMENTATION
=head2 Asciio user interface
.-----------------------------------------------------------------.
| Asciio |
|-----------------------------------------------------------------|
| ............................................................... |
| ..............-------------..------------..--------------...... |
| .............| stencils > || asciio > || box |..... |
| .............| Rulers > || computer > || text |..... |
| .............| File > || people > || wirl_arrow |..... |
grid---------->.......'-------------'| divers > || axis |..... |
| ......................^.....'------------'| boxes > |..... |
| ......................|...................| rulers > |..... |
| ......................|...................'--------------'..... |
| ......................|........................................ |
| ......................|........................................ |
| ......................|........................................ |
| ......................|........................................ |
'-----------------------|-----------------------------------------'
|
|
context menu
Press 'F1' for help.
=head2 context menu
The context menu allows to access to B<Asciio> commands.
=head2 keyboard shortcuts
All the keyboad commands definitions can be found under I<asciio/setup/actions/>. Among the commands
implemented are:
=over 2
=item * select all
=item * delete
=item * undo
=item * group/ungroup
=item * open / save
=item * local clipboard operations
=item * send to front/back
=item * insert arrow, boxes, text
=item * ...
=back
The available commands are displayed if you press B<K>.
=head2 elements
There are a few elements implemented at the moment.
=head3 wirl arrow
An arrow that tries to do what you want. Try rotating the end clockwise then counter clockwise to see how it acts
^
|
| --------.
| |
'------- |
|
O-------------X / |
/ |
/ |
/ v
/
/
v
=head3 multi section wirl arrow
A set of whirl arrows connected to each other
.----------. .
| | \ / \
.-------' ^ \ / \
| \ \ / \
| .-----------> \ ' .
| '----. \ /
| | \ /
'--------' '-------'
=head3 angled arrow and axis
-------. .-------
\ /
\ /
\ /
/ \
/ \
/ \
------' '-------
^
^ | ^
\ | /
\ | /
\ | /
<-------- -------->
/ |\
/ | \
/ | \
v | v
v
=head3 box and text
.----------.
| title |
.----------. |----------| ************
| | | body 1 | * *
'----------' | body 2 | ************
'----------'
anything in a box
(\_/) |
edit_me (O.o) <------------'
(> <)
You can also use the 'External commands in box' to direct an external command output to a box. Default shortcuts are 'x' and CTL + 'x'.
=head3 "if" box and "process" box
____________
.--------------. \ \
/ a == b \ \ \ __________
( && ) ) process ) \ \
\ 'string' ne '' / / / ) process )
'--------------' /___________/ /_________/
=head3 your own stencils
Take a look at I<setup/stencils/computer> for a stencil example. Stencils listed in I<setup/setup.ini> will
be loaded when B<Asciio> starts.
=head3 your own element type
For simple elements, put your design in a box. That should cover 90% of anyone's needs. You can look in
I<lib/stripes> for element implementation examples.
=head2 exporting to ASCII
You can export to a file in ASCII format but using the B<.txt> extension.
Exporting to the clipboard is done with B<ctl + e>.
=head1 EXAMPLES
User code ^ ^ OS code
\ /
\ /
\ /
User code <----Mode----->OS code
/ \
/ \
/ \
User code v v OS code
.---. .---. .---. .---. .---. .---.
OS API '---' '---' '---' '---' '---' '---'
| | | | | |
v v | v | v
.------------. | .-----------. | .-----.
| Filesystem | | | Scheduler | | | MMU |
'------------' | '-----------' | '-----'
| | | |
v | | v
.----. | | .---------.
| IO |<----' | | Network |
'----' | '---------'
| | |
v v v
.---------------------------------------.
| HAL |
'---------------------------------------'
.---------. .---------.
| State 1 | | State 2 |
'---------' '---------'
^ \ ^ \
/ \ / \
/ \ / \
/ \ / \
/ \ / \
/ v v
****** ****** ******
* T1 * * T2 * * T3 *
****** ****** ******
^ ^ /
\ \ /
\ \ /
\ \ / stimuli
\ \ /
\ \ v
\ .---------.
'--------| State 3 |
'---------'
.--Base::Class::Derived_A
lib/App/Asciio.pm view on Meta::CPAN
$self->run_actions(["${modifiers}-button_release", $event]) ;
return 1 ;
}
if(defined $self->{MODIFIED_INDEX} && defined $self->{MODIFIED} && $self->{MODIFIED_INDEX} == $self->{MODIFIED})
{
$self->pop_undo_buffer(1) ; # no changes
}
$self->update_display();
}
#-----------------------------------------------------------------------------
sub button_press_event
{
#~ print "button_press_event\n" ;
my ($self, $event, $wrapper_event) = @_ ;
$self->{DRAGGING} = '' ;
delete $self->{RESIZE_CONNECTOR_NAME} ;
$self->create_undo_snapshot() ;
$self->{MODIFIED_INDEX} = $self->{MODIFIED} ;
my $modifiers = $event->{MODIFIERS} ;
my $button = $event->{BUTTON} ;
if($self->exists_action("${modifiers}-button_press-$button"))
{
$self->run_actions(["${modifiers}-button_press-$button", $event]) ;
return 1 ;
}
my($x, $y) = @{$event->{COORDINATES}} ;
if($event->{TYPE} eq '2button-press')
{
my @element_over = grep { $self->is_over_element($_, $x, $y) } reverse @{$self->{ELEMENTS}} ;
if(@element_over)
{
my $selected_element = $element_over[0] ;
$self->edit_element($selected_element) ;
$self->update_display();
}
return 1 ;
}
if($event->{BUTTON} == 1)
{
my $modifiers = $event->{MODIFIERS} ;
my ($first_element) = first_value {$self->is_over_element($_, $x, $y)} reverse @{$self->{ELEMENTS}} ;
if ($modifiers eq 'C00')
{
if(defined $first_element)
{
$self->run_actions_by_name('Copy to clipboard', ['Insert from clipboard', 0, 0]) ;
}
}
else
{
if(defined $first_element)
{
if ($modifiers eq '00S')
{
$self->select_elements_flip($first_element) ;
}
else
{
unless($self->is_element_selected($first_element))
{
# make the element under cursor the only selected element
$self->select_elements(0, @{$self->{ELEMENTS}}) ;
$self->select_elements(1, $first_element) ;
}
}
}
else
{
# deselect all
$self->deselect_all_elements() if ($modifiers eq '000') ;
}
}
$self->{SELECTION_RECTANGLE} = {START_X => $x , START_Y => $y} ;
$self->update_display();
}
if($event->{BUTTON} == 2)
{
$self->{SELECTION_RECTANGLE} = {START_X => $x , START_Y => $y} ;
$self->update_display();
}
if($event->{BUTTON} == 3)
{
$self->display_popup_menu($wrapper_event) ; # display_popup_menu is handled by derived Asciio
}
return 1;
}
#-----------------------------------------------------------------------------
sub motion_notify_event
{
my ($self, $event) = @_ ;
my($x, $y) = @{$event->{COORDINATES}} ;
my $modifiers = $event->{MODIFIERS} ;
my $button = $event->{BUTTON} ;
if($self->exists_action("${modifiers}motion_notify"))
{
$self->run_actions(["${modifiers}-motion_notify", $event]) ;
( run in 1.201 second using v1.01-cache-2.11-cpan-df04353d9ac )