Yata - 2da editor

#44

+100

minimum reproducable: 2 files. save one, then save the other, and the filename changes to the one saved.

now i’m embarrased

 
okay i see the fault and think i nailed it – update should be in the Vault in ~30min

#45

IMPORTANT Update ver 2.7

fixed save bug when multiple files are open (ie, one file is saved then another file is saved)

https://neverwintervault.org/project/nwn2/other/tool/yata

 
tks Mairn

 
 
 
Ps. on a new front, have been putting in time on Undo/Redo … quite frankly it’s a mind***k the first time trying it.

1 Like
#46

getting there …


cell-changes seem solid, row insert/delete needs more attention

 
EDIT: getting closer … I think i understand the Undo/Redo system i’ve set up (yeh, that I set up…)

hopefully all that’s left to do is implement it for specific actions other than those that’ve been used for testing (various insert row/delete row operations) – and refactor out a now redundant State variable (that now seems to track merely the “changed” state of the 2da)

basically it turns out i’ve been overthinking it, making things more complicated than they need to be.

 
EDIT_2: methinks the UndoRedo class is complete. but have yet to implement it in several row-insert/delete functions.

 
EDIT_3: nope. It still needs an Overwrite(row) action … but the system (if not [yet] concise) has become understandable.

 
EDIT_4: O its getting good – action Overwrite() slid in like a charm  :)
next … and hopefully last … multi-row insert/delete

 
EDIT_5: Undo/Redo is basically done. There’s a few things i want to make friendlier before building another release version. :nerd_face: :snowman_with_snow::cookiemonster:

 
 
EDIT_6: DESIGN_FLAW. Since Undo/Redo identifies cells/rows by position it all screws up when cols are sorted.

for now i’ll probly just disable UR when the table is sorted by anything other than id-ascending ->

 
EDIT_7: think i patched it up by updating the row-ids in the Restorables – those ids ought remain current after a Sort.

tests indicate it works but permutations are through the roof

1 Like
#47

ver 2.8
https://neverwintervault.org/project/nwn2/other/tool/yata

Undo/Redo + tweaks and nuances

keep an eye on things especially if you’re sorting columns and using Undo/Redo in various combinations – inserting or deleting multiple rows in particular.

#48

ver 2.8.1

fixes
– trying to paste text to either the Searchbox or Gotobox with the keyboard [Ctrl+v] caused the currently selected cell to take the text instead.
– Gotobox defaults to “0” if a nonnumeric or negative value is entered.

feature
– Ctrl+mousewheel forces horizontal scroll if applicable.

notes
– don’t overwrite your settings file, it hasn’t changed. Only the ReadMe and executable have been changed.

1 Like
#49

Yata ver.2.8.2

  • clicking a label in the property panel selects the cell in the table (previous behavior was that a cell in the table would be selected only when a field in the property panel was being edited). Note that this auto-selection will be bypassed if more than one cell is currently selected on the table.
  • bugfix: allow shortcut keys for copy and paste [Ctrl+c] [Ctrl+v] to work in the PropertyPanel’s editor (instead of being intercepted by a copy/paste of the table’s selected gridcell).
#50

Version: 2.8.2.1

bugfix for Control press causing exception.

my stupid

#51

yata changelog ver.2.9.0.0
https://neverwintervault.org/project/nwn2/other/tool/yata

  • add CreateRows dialog (receive a bonus DarthVader quote on any error, see screenshot)
  • add shortcut [Ctrl+e] for SaveAs
  • add shortcuts to 2daOps menu
  • add mnemonics to all menus
  • fix/tighten many shortcuts’ Enabled/Disabled determinations
  • tweaks to Clipboard editor (no wordwrap, add Done button)
  • monitor changes on disk to opened files (deleted, moved, renamed, or saved outside of Yata)
  • SaveAll on the File menu (is Beta - be careful, make backups of open files first! SaveAll is Beta)
  • don’t beep when pressing [Enter] on Search or Goto
  • Ctrl+Left/Right: shifts table by visible width left/right
  • update ReadMe.txt

 
I’m the only guy testing these releases. And all i do is poke at it with my mouse for a while … but the state-space in a multi-tabbed app is, uh, large. So on a large release like this, be wary. Please keep your eye on things,

Do backups.

 
EDIT: am going to try to make some kind of a differ …

1 Like
#52

In that case you might want to check out WinMerge. It’s a free and open source differencing program and a link to the source can be found here.

TR

#53

thanks Tarot,

it totally passed me by that WinMerge is foss. At the moment such code is a bit extravagant, though; if I can simply get the cells of two loaded tables to show up with a different color (consistently, etc.) – that’s all i’m looking at right now.

sorta like so
yata_diff00

 
… a Merge function is, well, later. Then i might well scrape some calcification off my neurons and have a look,

#54

Another thought is that you could get Yata to spawn an instance of WinMerge with a command line featuring the two 2da files. Purely as a stop-gap until you can get around to writing your own comparison routines.

TR

1 Like
#55

found a bug that’s been lurking for a while … ie. when deleting multiple rows AND the id of the selected row is greater than the id(s) of the subselected rows, the range is negative but there are places where i didn’t account for that.

Workaround: when deleting rows, always select the lesser row first, then subselect [Shift+click] rows with a greater id-value

 
will be fixed, but am making progress on the differ atm

#56
/// <summary>
/// Handles a single-cell merge operation.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void cellclick_Merge(object sender, EventArgs e)
{
    YataGrid destTable = null;
    if      (Table == _diff1) destTable = _diff2;
    else if (Table == _diff2) destTable = _diff1;

    if (destTable != null) // safety.
    {
        Cell src = Table.getSelectedCell();
        int r = src.y;
        int c = src.x;

        Cell dst = destTable[r,c];
        destTable.ChangeCellText(dst, src.text);

        _diff1[r,c].diff =
        _diff2[r,c].diff = false;
    }
}

/heh I still like the idea of spawning WinMerge for big operations.

#57

erm, Isn’t this an error? Surely you need to have something to actually assign to _diff1[r,c].diff.

TR

#58

It’s not an error.


It’s equivalent to

_diff1[r,c].diff = _diff2[r,c].diff = false;

which reads as

_diff2[r,c].diff = false;
_diff1[r,c].diff = _diff2[r,c].diff;
#59

NwScript test 1

void main()
{
    int a,b;
    a = b = 1;
}
> Executing: C:\Program Files (x86)\ConTEXT\ConExec.exe "c:\nwn2\asc.exe" -ago -i C:\nwn2 -v1.69 "test.nss"

NWNScriptCompiler - built Jan 29 2014 19:24:04
Copyright (C) 2008-2014 Skywing.
Portions copyright (C) 2002-2003, Edward T. Smith.
Portions copyright (C) 2003, The Open Knights Consortium.
Compiling: test.NSS

test.nss(4): Warning: NSC6021: The standard compiler does not support nested
assignment RHS expressions that are themselves an assignment type expression.
Consider encapsulating the right-hand-side expression in parens (), or
unwrapping the nested assignment for compatibility with the standard compiler.

Total Execution time = 62ms

> Execution finished.

NwScript test 2

void main()
{
    int a,b;
    a = (b = 1);
}
> Executing: C:\Program Files (x86)\ConTEXT\ConExec.exe "c:\nwn2\asc.exe" -ago -i C:\nwn2 -v1.69 "test.nss"

NWNScriptCompiler - built Jan 29 2014 19:24:04
Copyright (C) 2008-2014 Skywing.
Portions copyright (C) 2002-2003, Edward T. Smith.
Portions copyright (C) 2003, The Open Knights Consortium.
Compiling: test.NSS

Total Execution time = 31ms

> Execution finished.

/vewy interesting

#60

sorta like so
yata_diff01

#61
/// <summary>
/// Starts an external diff/merger program with the two diffed files
/// opened. Usually WinMerge.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void opsclick_ExternalDiff(object sender, EventArgs e)
{
    if (File.Exists(Settings._diff))
    {
        var diff = new Process();
        diff.StartInfo.FileName = Settings._diff;

        if (_diff1 != null && _diff2 != null
            && File.Exists(_diff1.Fullpath)
            && File.Exists(_diff2.Fullpath))
        {
            diff.StartInfo.Arguments = " \"" + _diff1.Fullpath + "\" \"" + _diff2.Fullpath + "\"";
        }
        else
            diff.StartInfo.Arguments = " \"" + Table.Fullpath + "\"";

        diff.Start();
    }
}

thanks for the idea, Tarot, it works lovely  :blossom:

a) do a Yata diff
b) select 2daOps|External diff
c) apply WinMerge, save file
d) Yata’s file-monitor pops up -> reload 2da
e) profit.

- the path to Winmerge needs to be [EDIT] will need to be set manually in Yata’s “settings.cfg” [config file]

I might handle kdiff3 also … will see … WinMerge is more than good enough for 2da files  :|

 
ps. Turns out that kdiff3 accepts the same cl args … so user choice.

Edit: (rewrite function)

1 Like
#62

Appendix L: Yata diff

Yata version 3+ has an internal differ. A right-click on a table’s tab shows a
popup with several operations including these four:

  • Select diff1 (selects the currently displayed table as diff1)
  • Select diff2 (selects the currently displayed table as diff2)
  • Reset diffs (clears tables of their diff flags)
  • Justify tables (re-widths the cols of the two diffed tables so they are
    visually aligned)

Notes: diff1 must be selected before diff2. Diff2 can be re-selected, but
re-selecting diff1 causes diff2 to be cleared; diff2 must be selected after
diff1. Reloading a 2da causes its diff to be cleared.

Select diff2 causes four noticable things to happen:

  1. cells with texts that differ will be rendered with a teal background color
  2. the tables’ cols will be justified automatically
  3. the tables will scroll in unison if possible
  4. the DifferDialog will appear. It lists any differences between col headers
    and row counts. Additionally a Goto button in the lower left corner of the
    dialog can be used to cycle (forward only) through cell texts that are different
    in the two tables. Note that the count of cell differences includes the ID cols
    but their backgrounds will not be colored teal (since the ID col is a frozen
    col).

A right-click on a diffed cell shows a popup with several operations including
these two:

  • merge to other - Ce (copies the text in the selected cell to the other table)
  • merge to other - Ro (copies the texts of the row of the selected cell to the
    other table)

The selected cell’s position (x/y) must be present in both tables. Rows do not
have to be the same length; any cells that overflow will be filled with “****”.

Merges of multiple cells or rows is not allowed. That’s what Appendix M:
WinMerge is for …

 
Appendix M: WinMerge

The operation under 2da Ops->External diff/merger will be enabled if the path to
your WinMerge executable is specified in Settings.Cfg by the variable “diff=”

  • eg
    diff=C:\Program Files (x86)\WinMerge\WinMergeU.exe

A diff is performed in Yata from its Tab menu (see Appendix L: Yata diff). If
you are doing a diff and the External diff/merger is invoked, WinMerge should
start with the two diffed files loaded.

Note that if you’re not doing a diff in Yata and select the operation, WinMerge
should start with a dialog asking what file you’d like to diff against the
currently displayed 2da.

Also note that kdiff3 accepts the same commandline file arguments as WinMerge,
so the path to its executable can be assigned in Settings.Cfg if preferred.

If a file is saved in the external differ, Yata’s file monitor should pop up
asking what to do (Reload file, Close 2da, or Cancel).

#63

update 2019 may 22
ver.3.0.0.0
https://neverwintervault.org/project/nwn2/other/tool/yata

  • implement internal diff/merge operations (right-click a Tab: select diff1, select diff2, reset, justify tables)
  • implement var “diff=” in Settings.Cfg for an external diff/merge program (WinMerge, kdiff3)
  • fix Clear Undo/Redo’s enabled/disabled determination
  • underline the current tab’s text iff the tabcontrol has focus (as an indicator that the grid does not have focus)
  • change shift-page-by-visible-width’s modifier key to Shift+Left/Right (was Ctrl+Left/Right)
  • Shift+Mousewheel shifts table by visible height/width (Ctrl+Mousewheel already forces horizontal scroll if possible)
2 Likes