Skip to content

Commit

Permalink
ADDED: stencils as asciio files
Browse files Browse the repository at this point in the history
  • Loading branch information
nkh committed Dec 6, 2023
1 parent 347f9ba commit 3528467
Show file tree
Hide file tree
Showing 15 changed files with 98 additions and 18 deletions.
5 changes: 5 additions & 0 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ setup/Stencils/Computer
setup/Stencils/People
setup/Stencils/Divers

setup/Stencils/elements.asciio
setup/Stencils/computer.asciio
setup/Stencils/people.asciio
setup/Stencils/buildings.asciio

lib/App/Asciio.pm

lib/App/Asciio/Actions.pm
Expand Down
2 changes: 1 addition & 1 deletion documentation/mdbook_asciio/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
- [Keyboard](editing/keyboard.md)
- [Mouse](editing/mouse.md)
- [Cloning](editing/cloning.md)
- [Drag and Drop](editing/drag_drop.md)
- [Stencils and "Drag and Drop"](editing/drag_drop.md)
- [Strip groups](editing/strip-groups.md)

- [Export/Save](exporting.md)
Expand Down
24 changes: 23 additions & 1 deletion documentation/mdbook_asciio/src/editing/drag_drop.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
# Drag And Drop
# Stencils and "Drag And Drop"

## Stencils

You can access Stencils via "Drag and Drop".

Asciio has bindings to open stencils in a separate instance

**Start Binding:** is

Then uses one of the following keys:

| bindings | action |
| -------- | ------------------------------------------------------------ |
| s | select from user stencils in $HOME/.config/Asciio/stencils/ |
| d | open stencil 'default_stencil.asciio' from current directory |
| a | select stencil from your computer |
| 0 | open 'elements.asciio' from $HOME/.config/Asciio/stencils/ |
| 1 | open 'computer.asciio' from $HOME/.config/Asciio/stencils/ |
| 2 | open 'people.asciio' from $HOME/.config/Asciio/stencils/ |
| 3 | open 'buildings.asciio' from $HOME/.config/Asciio/stencils/ |

## Drag and Drop

***Binding:*** control + left click + drag

Expand Down
26 changes: 26 additions & 0 deletions lib/App/Asciio/Actions/Elements.pm
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,32 @@ if(defined $file_name && $file_name ne '')

#----------------------------------------------------------------------------------------------

sub open_user_stencil
{
my ($self, $file_name) = @_ ;

my $user_stencils_path = File::HomeDir->my_home() . '/.config/Asciio/stencils' ;

if(defined $file_name)
{
$file_name = "$user_stencils_path/$file_name" ;
}
else
{
# pick a file
$file_name = $self->get_file_name('', 'save', $user_stencils_path) ;
}

if(defined $file_name && $file_name ne '')
{
# todo: check path
system "asciio '$file_name' &" ;
}

}

#----------------------------------------------------------------------------------------------


sub add_help_box
{
Expand Down
2 changes: 1 addition & 1 deletion lib/App/Asciio/Dialogs.pm
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ return $answer ;

sub get_file_name
{
my ($self, $type) = @_ ;
my ($self, $title, $mode, $directory) = @_ ;

print "get_file_name:\n" ;

Expand Down
14 changes: 8 additions & 6 deletions lib/App/Asciio/GTK/Asciio/Dialogs.pm
Original file line number Diff line number Diff line change
Expand Up @@ -331,18 +331,20 @@ return $new_text

sub get_file_name
{
my ($self, $type) = @_ ;
my ($self, $title, $mode, $directory) = @_ ;

my $file_name = '' ;

my $file_chooser = Gtk3::FileChooserDialog->new
(
$type, undef, $type,
'gtk-cancel' => 'cancel', 'gtk-ok' => 'ok'
);
(
$title, undef, $mode,
'gtk-cancel' => 'cancel', 'gtk-ok' => 'ok'
);

$file_chooser->set_current_folder($directory) if defined $directory ;
$file_chooser->set_create_folders(1) ;
$file_name = $file_chooser->get_filename if ('ok' eq $file_chooser->run) ;

$file_chooser->destroy;
while(Gtk3::events_pending())
{
Expand Down
2 changes: 1 addition & 1 deletion lib/App/Asciio/Options.pm
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ do
{
while(@ARGV && $ARGV[0] !~ /^-/)
{
#~ print "target => $ARGV[0] \n" ;
# print "target => $ARGV[0] \n" ;
push @targets, shift @ARGV ;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/App/Asciio/Text/Asciio/Dialogs.pm
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ return $result // '' ;

sub get_file_name
{
my ($self, $type) = @_ ; # type: save|open
my ($self, $title, $mode, $directory) = @_ ; # type: save|open

print "\e[2J\e[H\e[?25h" ;

Expand Down
3 changes: 2 additions & 1 deletion script/asciio
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,14 @@ else
}

$asciio->setup($setup_paths) ;
$asciio->{ACTION_VERBOSE} = sub { print "@_\n" } ;
$asciio->{ACTION_VERBOSE} = sub { print STDERR "@_\n" } ;

my ($character_width, $character_height) = $asciio->get_character_size() ;

if(defined $asciio_config->{TARGETS}[0])
{
$asciio->run_actions_by_name(['Open', $asciio_config->{TARGETS}[0]]) ;

delete $asciio->{BINDINGS_COMPLETION} ;

$window->set_default_size(@{$asciio->{WINDOW_SIZE}}) if defined $asciio->{WINDOW_SIZE} ;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
18 changes: 15 additions & 3 deletions setup/Text/actions/vim_bindings.pl
Original file line number Diff line number Diff line change
Expand Up @@ -241,16 +241,28 @@
'Add ascii line' => ['l'],
'Add ascii no-connect line' => ['k'],

'From default_stencil' => ['s'],
'From stencil' => ['S'],

'<< Stencil >>' => ['s'] ,
'<< Multiple >>' => ['m'] ,
'<< Unicode >>' => ['u'] ,
'<< Box >>' => ['b'] ,
'<< Elements >>' => ['e'] ,
'<< Ruler >>' => ['r'] ,
},

'group_insert_stencil' =>
{
SHORTCUTS => 'group_insert_stencil',

'From user stencils' => ['s'],
'From default_stencil' => ['d'],
'From any stencil' => ['a'],

'From user elements' => ['0'],
'From user computer' => ['1'],
'From user people' => ['2'],
'From user buildings' => ['3'],
},

'group_insert_multiple' =>
{
SHORTCUTS => 'group_insert_multiple',
Expand Down
18 changes: 15 additions & 3 deletions setup/actions/default_bindings.pl
Original file line number Diff line number Diff line change
Expand Up @@ -267,16 +267,28 @@
'Add ascii line' => ['000-l', \&App::Asciio::Actions::Elements::add_line, 0 ],
'Add ascii no-connect line' => ['000-k', \&App::Asciio::Actions::Elements::add_non_connecting_line, 0 ],

'From default_stencil' => ['000-s', \&App::Asciio::Actions::Elements::open_stencil, 'default_stencil.asciio' ],
'From stencil' => ['00S-S', \&App::Asciio::Actions::Elements::open_stencil ],

'<< Stencil >>' => ['000-s', sub { $_[0]->use_action_group('group_insert_stencil') ; } ] ,
'<< Multiple >>' => ['000-m', sub { $_[0]->use_action_group('group_insert_multiple') ; } ] ,
'<< Unicode >>' => ['000-u', sub { $_[0]->use_action_group('group_insert_unicode') ; } ] ,
'<< Box >>' => ['000-b', sub { $_[0]->use_action_group('group_insert_box') ; } ] ,
'<< Elements >>' => ['000-e', sub { $_[0]->use_action_group('group_insert_element') ; } ] ,
'<< Ruler >>' => ['000-r', sub { $_[0]->use_action_group('group_insert_ruler') ; } ] ,
},

'group_insert_stencil' =>
{
SHORTCUTS => 'group_insert_stencil',

'From user stencils' => ['000-s', \&App::Asciio::Actions::Elements::open_user_stencil ],
'From default_stencil' => ['000-d', \&App::Asciio::Actions::Elements::open_stencil, 'default_stencil.asciio' ],
'From any stencil' => ['000-a', \&App::Asciio::Actions::Elements::open_stencil ],

'From user elements' => ['000-0', \&App::Asciio::Actions::Elements::open_user_stencil, 'elements.asciio' ],
'From user computer' => ['000-1', \&App::Asciio::Actions::Elements::open_user_stencil, 'computer.asciio' ],
'From user people' => ['000-2', \&App::Asciio::Actions::Elements::open_user_stencil, 'people.asciio' ],
'From user buildings' => ['000-3', \&App::Asciio::Actions::Elements::open_user_stencil, 'buildings.asciio' ],
},

'group_insert_multiple' =>
{
SHORTCUTS => 'group_insert_multiple',
Expand Down

0 comments on commit 3528467

Please sign in to comment.