nkh / P5-App-Asciio

Plain ASCII diagram
https://nkh.github.io/P5-App-Asciio/
56 stars 4 forks source link

Refactor: Asciio::Element module #40

Closed nkh closed 1 year ago

nkh commented 1 year ago

@qindapao, most of the module is code you added for cross and line handling, I recommend you start by refatoring that code in a separate module, Asciio::Element::Cross or something like that.

I notice that you've added

   'Cross element Insert leader' => 
{
SHORTCUTS => '000-x',

which is good but I'd like to set a few directives for that, please look in this ticket #39

 23  sub set_modified_state { my ($self, $state) = @_ ; $self->{MODIFIED} = $state ; }
 27  sub get_modified_state { my ($self) = @_ ; $self->{MODIFIED} ; }
 31  sub get_group_color
 46  sub add_ruler_lines
 54  sub remove_ruler_lines
 78  sub exists_ruler_line
105  sub add_new_element_named
123  sub add_new_element_of_type
137  sub set_element_position
146  sub add_element_at
154  sub add_element_at_no_connection
164  sub add_elements
172  sub add_elements_no_connection
184  sub create_cross_elements
208  sub unshift_elements
217  sub move_elements
321  sub resize_element
396  sub move_elements_to_front
413  sub move_elements_to_back
430  sub delete_elements
452  sub edit_element
523  sub get_selected_elements
545  sub any_select_elements
554  sub select_elements
602  sub select_all_elements_by_search_words
616  sub select_all_elements_by_search_words_ignore_group
630  sub select_cross_filler_elements_from_selected_elements
648  sub select_cross_elements_from_selected_elements
666  sub select_normal_elements_from_selected_elements
684  sub select_normal_filler_elements_from_selected_elements
702  sub switch_to_normal_elements_from_selected_elements
727  sub switch_to_cross_elements_from_selected_elements
752  sub switch_cross_mode
771  sub select_all_elements
780  sub deselect_all_elements
789  sub select_elements_flip
803  sub is_element_selected
812  sub is_over_element
840  sub element_completely_within_rectangle
888  sub pixel_to_character_x
899  sub pixel_to_character_y
910  sub closest_character
992  sub delete_cross_elements_cache

1006 sub add_cross_elements 1093 sub scene_cross 1112 sub scene_dot 1128 sub scene_apostrophe 1142 sub scene_unicode_cross 1156 sub scene_unicode_cross_lose_right 1171 sub scene_unicode_cross_lose_left 1186 sub scene_unicode_cross_lose_up 1201 sub scene_unicode_cross_lose_down 1216 sub scene_unicode_right_down 1231 sub scene_unicode_left_down 1246 sub scene_unicode_left_up 1261 sub scene_unicode_right_up 1276 sub scene_x 1291 sub scene_unicode_x 1307 sub create_line

qindapao commented 1 year ago

@nkh d2aa6429b691dd4ab6fe077abb980daf53c820ed

I still don't understand how to set up vim's related bindings I added three colors so you need to update your config file for this to work

        cross_element_backgroud => [0.93, 0.93, 0.88],
        cross_filler_background => [0.83, 0.83, 0.78],
        normal_filler_background => [1.00, 0.88, 1.00],

gui.pl

Only updating basic.pl cannot get these nested hash values. When basci.pl and gui.pl coexist.

nkh commented 1 year ago

there's almost no difference between setting up bindings in the gui and the tui

let me explain why we want to use vim-like bindings, let's say, to simplify, that we just have 26 letters, no uppercase

combinations

using ctl + alt + key gives us around 100 combinations letter + letter + letter gives use around 18 000

if we hade uppercase, ie, 52 letters using ctl + alt + key gives us around 200 combinations letter + letter + letter gives use around 140 000

speed

typing ctl + alt + key is not faster than key + key + key, and even less key + key

structure and mnemonics

of course we don't need tens of thousands of combinations

do you know what CA0-a does? C0S-A? 0AS-a? CAS-A? C00-A? 0A0-a? 00S-a? ... without looking at the docs

if noticed that you defined a sub binding group with some binding needing the control key to be pressed, you'll soon see that it's very difficult to remember.

the whole point vim-like binding is to remember them, it's not a perfect system but it's expandable and easier to remember

let me give you and example, we have multiple types of boxes, let's say

let' start with a generic binder «i» for insert then «b» for box

the good thing here is that we can use the same thing for arrows but with «ia» as a prefix

but let's imagine that you come up with 4 new types of unicode borders (well you have), I don't want to imagine how to do that with the mouse, and with ctl + .... we've run out of shortcuts that are easy to remember. on the other hand ...

I used 1, 2, and 3 because I was lacking imagination but

would have given us keys to remember.

now a quick questionary, do you remember (although you've just seen it):

insert a box, a box using unicode type 2, a box that shrinks, a box with the default unicode?

refactoring

Don't worry about the vim-bindings right now. as soon as i have some time I'll got through all the bindings and propose a change, specially for gui shortcuts, and create those that are missing.

nkh commented 1 year ago

No you can't really change nested hash values, not easily, this happens seldom so it's OK

I looked at your commit, good work, I propose you don't do more work on that branch before I merge it, it looks like I will have to do it manually.

Work on another part, one that you can branch from my main branch, not the old main branch.

how did it go with the synching via github?

qindapao commented 1 year ago

@nkh

synching via github Your main branch has been completely synchronized, and there seems to be no problem at present.

qindapao commented 1 year ago

The development I have done on your latest branch has no conflict.

About shortcut keys, to be honest, I really can't remember. I'm using it now while viewing default_binding.pl! ! !

Vim's mode is correct.

nkh commented 1 year ago

It's merged and I have added a commit about vim-like bindings.

I will run tests and try to understand the Cross mode, there's a lot to learn.