Enough Goofing Off (in a Dopamine Hole), Time to Dive into Hard Tasks Again

This post is part of a showcase of how a "story board" is invaluable in helping to develop the code (e.g. Python) for implementing the desired outcome. [more on storyboarding (here), (here), and (here)]

In my previous post (here) I took a pass at explaining my below, "partial" flowchart for my "Xpander" project. Now it's time to explain the details, this again happening well BEFORE writing any of the corresponding Python code.

(click on the image to enlarge it, back a page to return to here) (or get image separately  here)

Just to recap the overall scheme:

    (a) First, I decided I was going to parse the incoming text into three buckets, or buffer "lists" (as I will be implementing them). The decision of which buffer to dump the next incoming piece of text into is performed by a three state, sequential state machine having states S0, S1, S2 and then looping back to S0.

[Post script: A new idea just came to me : Add a fourth buffer, call it "Buff-previewer". It will show a temporary sample --not necessarily the whole thing-- of the expanded Abv before all the lone P3's or lone P4's are typed in. (Assuming the text is coming in from a simulated typewriter.) If the user goes above a max number of allowed 
P3's or P4's, the software cycles the P count back down to 1. In other words, the user can circle through and preview all the permutations and see the results just by typing a lot of P's]   

    (b) The flow chart (without inclusion of the above new idea) starts at the step labeled "ENTER" (also labeled as step number 05b which occurs when we switch from S2 back to S0) 

    (c) In initializing step 05c, we set the State tracker to S0 (purely for debug purposes, it's not needed by the algorithm itself)

    (d) Recall that we have two possible characters that can act as triggers, P3 and/or P4. In one embodiment P3 is the back tilted single quote mark at the top left of the keyboard and P4 is the tilde (~) which occurs when we up shift the same key. We initialize both P counts to zero in step 05c.

    (e) In step number 00 we do a negative test for presence of one of the P3 or P4 triggers. If not present, we loop around and keep dumping the incoming text characters into the first buffer, namely, Buff_0. Note to myself= need a limit on how big Buff_0 is and need to empty the front half of Buff_0 if it's near full, preferably making the break at a space character (" ") or some other punctuation (e.g.: period, colon, multiple colons (:::), comma, multiple commas (,,,), semicolon, normal quote mark, CRLF, TAB, ...) while retaining that breaker char in Buff_0 for the case where the next incoming character is a trigger (a P3 or a P4).

    (f) If a P3 is encountered in Step 00, we advance to Step 01. Recall that P3 means we are using the immediately preceding character (if any) as a single char abbreviation that is to be Xpanded by the instantiated Xpander object. So in Step 01 we verify that there was a valid preceding char (not a null or a CRLF). If not, we go to special continuation case Step Cx1 (not yet flow-charted) which handles the case of no preceding char. Otherwise, we continue to Step 02a where we move the first encountered P3 and its preceding one char to Buff_1. In step 02b we switch to machine state S01 and increment the P3 count to 1. 

ASIDE: To the right we have, for sake of a detour from boring verbiage, an explanation of sequential state machines. More can be found (HERE). (... and yet more here)

    (g) Next, in Step 03a, we get the next char out of the incoming text stream. There are 3 possibilities at this stage:
        (g1) that next char is also a P3, in which case we loop back to Step 3a by way of 3b where we increment the P3 count and append that new P3 to Buff_1.
        Else, another possibility is (g2) in which a P4 is encountered. In response to that occurrence, we append that new P4 to Buff_1, increment the P4 count and continue out to step Cx34 for handling the mixed P3P4 situation (the flow for Cx34 is not yet flow charted). 
        Else, another possibility is (g3) in which neither a consecutive P3 or P4 is encountered. In that case, the P3/P4 sequence is finished and the next char goes into Buff_2. Note that such a next non-P character can be an extension indicator such as a period (.), multiple periods (,,,), multiple colons (:::)  in which case Buff_2 will contain the extension parameter of limited length, for example the name of a parameters list terminating in a space or a hexadecimal index value or ??? 
    Else, another possibility is (g3') in which we do not detect an extension trigger but rather a normal non-P character. In that case, the P3/P4 sequence is finished and the system advances from Step 04b to 05a where we output (we return from the analysis function) the count of the detected consecutive P3's. We also return the lone Abv character for expansion in accordance with the P3 count. We clear Buff's 0, and 2. We add the new "other" character to the front of the cleared Buff_0 and advance to Step 05b (ENTER)  for repeating the whole thing over once more ... TO BE CONTINUED

Incidental Find of "Text Expanders" from Other Sources

In hindsight, I should not have been surprised that others on the internet have already devised their own text Xpanders, as generally noted in this query:
    QAB-g = Text Expanders
        ^^^-- Textexpander.com (paid) works with a semicolon as a pre-fix trigger
        ^^^-- Espanso , Autohotkey , Text Blaze(for browser) , Phrase Express , Brevvy ,
                Atext , Beeftext  --from (Red here) , Phraseexpander
                QAB ::: (Espanso here), Espanso.org (here) == uses colon (:) as prefix trigger

Incidental Find of "Drag Gestures" from Other Sources

    QAB-g = Windows Mouse-Drag Gestures
        ^^^-- ALT drag generates a short cut
(ACI) -- 
Mouse Gestures Extension in Windows 10 | Cool Features in Windows 10







MORE TO EXPLORE



Comments

Popular posts from this blog

Links for Python Noobs

The Learn HOW to Learn Page

My 1st and 2nd OOP class definitions (aka What is an OOP class definition?)