XMetaL Tips and Tricks

XMetaL Community Forum XMetaL Tips and Tricks Tip: Getting between closing tags in Normal View

  • dcramer

    Tip: Getting between closing tags in Normal View

    Participants 8
    Replies 9
    Last Activity 13 years, 11 months ago

    Say your cursor is where the | is below, immediately after /tmp and you want to type some text after the closing tag but still before the closing tag. If you're in Normal View (or even in Tags On and you don't like using the mouse too much), what do you do? In Normal View it's just impossible to get there as far as I can tell:


        On the Administration server host, copy foo.war to the /tmp directory: cp $DISTRIBUTION/ear/prt-tools-remoteControl.war /tmp|

    I use the following two macros. The jump me immediately outside of the current element. I'd be interested to hear what other techniques people have come up with to solve this problem. It seems that without a solution, Normal View is useless.

    Btw, suddently, Ctrl+Alt+RArrow and Ctrl+Alt+LArrow don't work over Remote Desktop, so I'm looking for a new keybinding. Maybe Ctrl+Alt+Shift+RArrow, tho that's a strain on the fingers.

    Selection.SelectAfterNode(Selection.ContainerNode);
    }catch(e){}]]>

    try{
    Selection.SelectBeforeNode(Selection.ContainerNode);
    }catch(e){}]]>

    Reply

    mag3737

    Reply to: Tip: Getting between closing tags in Normal View

    There's no real “solution” right now, but many people have workarounds.

    As one of those people who don't like the mouse too much, in this exact situation I would probably do Ctrl-SPACE to switch to tags view, then RArrow, then my typing, then (assuming I meant to continue working in Normal view) Ctrl-SPACE again to switch back.

    I'd also be interested to hear other macro-related things that people may do.

    Reply

    Derek Read

    Reply to: Tip: Getting between closing tags in Normal View

    I feel for people that want to work in Normal view but that have run into this limitation. David's macro looks like a good workaround to me. Ideally I'd like to see us extend the standard UI to do this without needing to do this type of workaround. The decision to stop people from moving their cursor (insertion point) in Normal view into a location that does not permit text is not clear to me and was made long ago (and one of the things we try to strive for is backward compatibility). However, one of the best things about XMetaL is that because it is so customizable (we're currently way over 1000 APIs) most of the time it lets you “fix” things you don't like about it.

    My Alternative Solution: I have a macro that could be integrated into any customization fairly easily. I'd like to perfect it a little more before posting (and technically I'm on vacation right now so shouldn't even be sneaking peeks here, my family would not approve 😉 I think it can be made to work for any DTD at the application-level (perhaps with a little bit of macro trickery).

    The macro adds three new sub-menus to the context menu:
    1) Insert Element Here
    2) Insert Element After
    3) Attributes

    Insert Element: Basically identical to the Element List it lists as sub-items all the elements that can be validly inserted at the current position. I did this because I like to work close to my content and so I don't need to move my eyes back and forth to the Element List. It also lets me keep the Element List closed, giving me more screen real estate for my documents. Selecting any element listed in this menu inserts it at the current position just like the Element List.

    Insert Element After: Exactly the same as “Insert Element” except that it lists items that can be inserted immediately after the current element (right after the closing ) and inserts them there when you select one. This is an alternative solution to David's though at the moment it only solves his exact scenario as described but has a few other limitations. It does let you insert HERE for example.

    Attributes: Same idea as the first two except this lists all attributes allowed for the current element along with any value that is currently set (identical to the Attribute Inspector). Clicking on an attribute that allows text (typically CDATA) shows a simple prompt dialog (text box popup) that allows you to set, remove and change whatever the current value is. For attributes that are defined as enumerated lists another sub-menu listing allowed values (according to the DTD) appears. This menu lets you select from one of the items to set it, and if something is already set an additional item is listed at the top that lets you remove the attribute. Items with fixed values in the DTD are simply displayed and cannot be altered. Basically, I've moved the Attribute Inspector to the Context Menu. Perhaps not a big deal, except that (again) you're editing stuff “in context” so you don't need to move your eyes as much (or your mouse if you use the mouse) as well as letting you keep the Attribute Inspector closed to give you more document editing space.

    I'll try to remember to post this when I get back to work (please remind me in early January if you don't see anything here shortly after January 5th).

    Happy Holidays!

    Reply

    dcramer

    Reply to: Tip: Getting between closing tags in Normal View

    Hi Derek,
    There are some other cases your macros won't cover. Say my cursor is where the | is below and I want to put some text outside the emphasis but inside the para:

    Some text foo|

    I'd need an “Insert text after” macro. But then, what if I have the following and want to put text (or an element for that matter) after the emphasis and before the para:

    Some text foo bar|

    Likewise, what if I have the following and want to add a listitem before or after the current listitem:

    |foo

    As you mention, your insert element after macro won't help, but you also need an “Insert element before” macro.

    I'll give your macros a try, but I think you still need mine to handle all cases. Also, I'd argue that mine is a simpler approach. With my movement macros, the only thing I'd ask for is some improved visual cue (like some kind of transient boxes or labels that popup and go away) to show you where you've landed.

    David

    Reply

    Derek Read

    Reply to: Tip: Getting between closing tags in Normal View

    If you do move the cursor into the right postion (via script or otherwise) that will be reflected in the “mini context” menu, which appears as a sort of sideways (or flattened) treeview below the document. This is constantly updated automatically in both TagsOn and Normal views.

    DITA example:
    topic / body / p
    Meaning: you're in a

    element inside a and the root is

    DocBook example (similar to your first example but assuming the document root is not

    but one of the more typical DocBook root elements):
    book / chapter / para / emphasis
    Meaning: you're in an element inside a

    inside a and the root is

    Perhaps we could improve this somehow, though I'm not sure what additional information we could put in there to help.

    Reply

    dcramer

    Reply to: Tip: Getting between closing tags in Normal View

    Yes, I rely heavily on that “mini context” thing. It's pretty subtle though and hard to keep an eye one even for an experienced user who knows to look for it. I think that information could be more prominent somehow.

    On the other hand, I'm probably the only person here who uses Normal view. I think that's sad and says a lot about the usability problems. For me, the cleaner look of Normal view helps me focus on the content. I honestly don't know how people deal with narrow columns in tables when there are lots of long tags. For me, the actual text content is often invisible in tags on view in that situation.

    Reply

    ghkrause

    Reply to: Tip: Getting between closing tags in Normal View

    Hi Derek,
    In December 2008 you announced that you would post some code in January here. Either no one reminded you or you posted that code somewhere else in the forum?
    Please give me a hint, your code would be of help for me now.

    Reply

    dcramer

    Reply to: Tip: Getting between closing tags in Normal View

    Was just looking back at this thread after ghkrause's post. I notice what I think is a typo in Derek's post:

    Shouldn't:

    “It does let you insert HERE for example.”

    instead be:

    “It does not let you insert HERE for example.”

    David

    Reply

    Derek Read

    Reply to: Tip: Getting between closing tags in Normal View

    Having a hard time finding this particular script in my backup files (my computer needed to be reformatted around January-ish). I'm going through my email archives now as I'm sure I emailed this to somebody at some point.

    I have found a version that is specific for attributes however. It uses the same basic trick to get around the fact that you can't pass parameters directly into a (which is the really useful part to all this stuff). Worst case scenario is that I might need to rewrite the elements one.

    Reply

    Derek Read

    Reply to: Tip: Getting between closing tags in Normal View

    I found my old code and cobbled it back together. Part of this was to demo implementing an Attribute Inspector-like UI on the context menu, and it was basically working, but for some reason the insert element stuff was in bits and pieces inside an XFT which I didn't really like and which just complicated things.

    I've posted it here: http://forums.XMetaL.com/index.php/topic,738.0.html

    Note: The part of this big messy demo that is specifically relevant to this thread (how do I more easily insert something between tags in normal view?) appears in my new context menu items as “Insert Element…” > “…immediately after …”

    Reply

  • You must be logged in to reply to this topic.

Lost Your Password?

Products
Downloads
Support