Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

26
LINES

< > BotCompany Repo | #1030589 // Diff Two Texts

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 1113K of libraries. Click here for Pure Java version (14823L/71K).

!7

cmodule DiffTwoTexts {
  S text1, text2;
  S diff;
  switchable bool trim = true;

  visual centerAndSouth(hgridWithSpacing( //jhsplit3(
    withTitle("Text A (-)", dm_textArea text1()),
    withTitle("Diff", withMargin(wrap(dm_textArea diff()))),
    withTitle("Text B (+)", dm_textArea text2())),
    centeredLine(setToolTip("Also ignores empty lines", dm_checkBox("Ignore Indent", 'trim))));
    
  start {
    dm_watchFields(ll("text1", "text2", "trim"), r doDiff);
  }

  void doDiff enter {
    setField(diff := unidiff(preprocess(text1), preprocess(text2)));
  }

  S preprocess(S s) {
    if (trim) s = fullTrim(s);
    ret s;
  }
}

Author comment

Began life as a copy of #1016809

download  show line numbers  debug dex  old transpilations   

Travelled to 5 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt, wnsclhtenguj

No comments. add comment

Snippet ID: #1030589
Snippet name: Diff Two Texts
Eternal ID of this version: #1030589/8
Text MD5: 5b0a97f96cad573097d7613f7f5709f4
Transpilation MD5: 9d5b8ab2b3f742da8108a1ae4d80185f
Author: stefan
Category: javax
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2023-07-27 20:43:01
Source code size: 644 bytes / 26 lines
Pitched / IR pitched: No / No
Views / Downloads: 493 / 2066
Version history: 7 change(s)
Referenced in: [show references]