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).

1  
!7
2  
3  
cmodule DiffTwoTexts {
4  
  S text1, text2;
5  
  S diff;
6  
  switchable bool trim = true;
7  
8  
  visual centerAndSouth(hgridWithSpacing( //jhsplit3(
9  
    withTitle("Text A (-)", dm_textArea text1()),
10  
    withTitle("Diff", withMargin(wrap(dm_textArea diff()))),
11  
    withTitle("Text B (+)", dm_textArea text2())),
12  
    centeredLine(setToolTip("Also ignores empty lines", dm_checkBox("Ignore Indent", 'trim))));
13  
    
14  
  start {
15  
    dm_watchFields(ll("text1", "text2", "trim"), r doDiff);
16  
  }
17  
18  
  void doDiff enter {
19  
    setField(diff := unidiff(preprocess(text1), preprocess(text2)));
20  
  }
21  
22  
  S preprocess(S s) {
23  
    if (trim) s = fullTrim(s);
24  
    ret s;
25  
  }
26  
}

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: 503 / 2095
Version history: 7 change(s)
Referenced in: [show references]