Giter Site home page Giter Site logo

Comments (8)

wumpz avatar wumpz commented on June 2, 2024

Thx. Could you be more specific, give a better example. However if you simply refer to the tags and how you could add some more markdown stuff you have to adapt the oldTag, newTag method calls. However this only works, if the Android textview supports some kind of css, html or markdown styling. So this should be sufficient regarding to (https://www.myandroidsolutions.com/2017/09/29/android-html-textview/#.Y-K2K3bMJaY).

DiffRowGenerator generator = DiffRowGenerator.create()
                .showInlineDiffs(true)
                .inlineDiffByWord(true)
                .oldTag(f -> "~")      //introduce markdown style for strikethrough
                .newTag(f -> "**")     //introduce markdown style for bold
                .build();

The oldTag, newTag methods are used to provide a Function<Boolean, String>. This function is called with true before the changed text and with false after it. So this should do it:

DiffRowGenerator generator = DiffRowGenerator.create()
                .showInlineDiffs(true)
                .inlineDiffByWord(true)
                .oldTag(f -> f?"<font color='red'>":"</font>")      //introduce html style for strikethrough
                .newTag(f -> f?"<font color='green'>":"</font>")     //introduce html style for bold
                .build();

from java-diff-utils.

developer-krushna avatar developer-krushna commented on June 2, 2024

@wumpz

Thank you sir for your reply..I really very greatful to you.. And it's working...
Screenshot_2023-02-08-07-22-01-672

But one thing, Actually I am trying to make an app that can compare 2 text files.. But in my code

DiffRowGenerator generator = DiffRowGenerator.create()
.showInlineDiffs(true)
.inlineDiffByWord(true)
.oldTag(f -> f?"<font color='red'>":"</font>")
.newTag(f -> f?"<font color='green'>":"</font>")
.build();
List<DiffRow> rows = generator.generateDiffRows(
Arrays.asList(FileUtil.readFile("/storage/emulated/0/Engine.java")),
Arrays.asList(FileUtil.readFile("/storage/emulated/0/Engine (1).java")));
for (DiffRow row : rows) {
  textview1.setText(Html.fromHtml(row.getNewLine(), >Html.FROM_HTML_MODE_COMPACT));
  textview2.setText(Html.fromHtml(row.getOldLine(), >Html.FROM_HTML_MODE_COMPACT));
}

``

Here I defined all the requirements but I am confused, after text comparator why textview showing only the text line where the text is deleted or modified ... Just see my image , this portion is modified and it only showing in the textview. not my other text ....How to solve it ..Thanks ❤️

from java-diff-utils.

wumpz avatar wumpz commented on June 2, 2024

generator.reportLinesUnchanged(true) delivers unchanged lines as well.

from java-diff-utils.

developer-krushna avatar developer-krushna commented on June 2, 2024

@wumpz

Sir giving same result..only one line even the if file have 3 line and 2nd and 3rd line have some text changes..but after text compare only showing the last line modification comparison not the 2nd line

from java-diff-utils.

wumpz avatar wumpz commented on June 2, 2024

You overwrite the previous line within your for loop. setText replaces text and does not append. So no problem with the diff tool.

from java-diff-utils.

developer-krushna avatar developer-krushna commented on June 2, 2024

@wumpz sir explain more clearly sir I unable to understand...Sir I am new

progressDialog = new ProgressDialog(MainActivity.this);
progressDialog.setMessage("Processing...");
progressDialog.show();
final Handler mHandler = new Handler() {
public void handleMessage(Message msg) {
progressDialog.dismiss();
}
};
new Thread() {
public void run() {
Looper.prepare();
try {
DiffRowGenerator generator = DiffRowGenerator.create()
.showInlineDiffs(true)
.inlineDiffByWord(true)
.replaceOriginalLinefeedInChangesWithSpaces(false)
.reportLinesUnchanged(true)
.ignoreWhiteSpaces(false)
.oldTag(f -> f?"":"")
.newTag(f -> f?"":"")
.build();
List rows = generator.generateDiffRows(
Arrays.asList(textview1.getText().toString()),
Arrays.asList(textview2.getText().toString()));
for (DiffRow row : rows) {
textview1.setText(textview1.getText().toString() + Html.fromHtml(row.getNewLine(), Html.FROM_HTML_MODE_COMPACT));
textview2.setText(textview2.getText().toString() + Html.fromHtml(row.getOldLine(), Html.FROM_HTML_MODE_COMPACT));
}
} catch (Exception e) {
SketchwareUtil.showMessage(getApplicationContext(), e.toString());
}
mHandler.sendEmptyMessage(0);
Looper.loop();
} }.start();
``

I have set a loop here but not working...
Screenshot_2023-02-14-08-28-37-237
There is 3 errors but it don't mentioning in comparison

Explain me with this code sir ....for which I can use it in my project thank you ♥️

from java-diff-utils.

wumpz avatar wumpz commented on June 2, 2024

At first glance, you do not use your original DiffRowGenerator anymore. Why? It worked. Now you do not include any formatting tags into your found diffs

.oldTag(f -> f?"":"")
.newTag(f -> f?"":"")

What does this do? Nothing. So nothing is hilited in your text.

from java-diff-utils.

github-actions avatar github-actions commented on June 2, 2024

Stale issue message

from java-diff-utils.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.