фикс подсветки.
This commit is contained in:
2
.idea/workspace.xml
generated
2
.idea/workspace.xml
generated
@@ -8,8 +8,6 @@
|
|||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="e42177c3-2328-4b27-8a01-35779b2beb99" name="Default Changelist" comment="">
|
<list default="true" id="e42177c3-2328-4b27-8a01-35779b2beb99" name="Default Changelist" comment="">
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/properties" beforeDir="false" afterPath="$PROJECT_DIR$/properties" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/Visual/Menus/MainMenuBar/MainMenuBar.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/Visual/Menus/MainMenuBar/MainMenuBar.java" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/Visual/Windows/ComparisonForm.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/Visual/Windows/ComparisonForm.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/Visual/Windows/ComparisonForm.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/Visual/Windows/ComparisonForm.java" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
"ServerUserPassword": "mprit_2011",
|
"ServerUserPassword": "mprit_2011",
|
||||||
"OfferRegistrationOnStart": true,
|
"OfferRegistrationOnStart": true,
|
||||||
"Workspace": "E:\\Tests",
|
"Workspace": "E:\\Tests",
|
||||||
"ProjectsSearchDirectory": "E:\\BUG",
|
"ProjectsSearchDirectory": "E:\\Tests\\Downloads",
|
||||||
"DocumentsDirectory": "C:\\Users\\misha\\Documents\\_testing_system",
|
"DocumentsDirectory": "C:\\Users\\misha\\Documents\\_testing_system",
|
||||||
"VisualiserPath": "C:\\Users\\misha\\Downloads",
|
"VisualiserPath": "C:\\Users\\misha\\Downloads",
|
||||||
"Sapfor_FPath": "E:\\_sapfor_x64\\Components\\Sapfor_F",
|
"Sapfor_FPath": "E:\\_sapfor_x64\\Components\\Sapfor_F",
|
||||||
|
|||||||
@@ -9,9 +9,6 @@ import Common.Visual.Menus.VisualiserMenuBar;
|
|||||||
import Common.Visual.UI;
|
import Common.Visual.UI;
|
||||||
import _VisualDVM.ProjectData.Files.UI.Editor.SPFEditor;
|
import _VisualDVM.ProjectData.Files.UI.Editor.SPFEditor;
|
||||||
import _VisualDVM.Utils;
|
import _VisualDVM.Utils;
|
||||||
import com.github.difflib.DiffUtils;
|
|
||||||
import com.github.difflib.patch.AbstractDelta;
|
|
||||||
import com.github.difflib.patch.Patch;
|
|
||||||
import com.github.difflib.text.DiffRow;
|
import com.github.difflib.text.DiffRow;
|
||||||
import com.github.difflib.text.DiffRowGenerator;
|
import com.github.difflib.text.DiffRowGenerator;
|
||||||
import javafx.util.Pair;
|
import javafx.util.Pair;
|
||||||
@@ -19,17 +16,14 @@ import org.fife.ui.rsyntaxtextarea.RSyntaxTextAreaHighlighter;
|
|||||||
import org.fife.ui.rtextarea.RTextScrollPane;
|
import org.fife.ui.rtextarea.RTextScrollPane;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
import javax.swing.text.Highlighter;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
public abstract class ComparisonForm<T> {
|
public abstract class ComparisonForm<T> {
|
||||||
public Class<T> t; //класс объектов.
|
public Class<T> t; //класс объектов.
|
||||||
//-->>
|
//-->>
|
||||||
public Vector<String> lines = new Vector<>(); //строки с учетом/неучетом пробелов. для сравнения
|
public Vector<String> lines = new Vector<>(); //строки с учетом/неучетом пробелов. для сравнения
|
||||||
public Vector<String> visible_lines = new Vector<>(); //строки с нетронутыми пробелами. для отображения
|
public Vector<String> visible_lines = new Vector<>(); //строки с нетронутыми пробелами. для отображения
|
||||||
//подсветка.
|
|
||||||
public RSyntaxTextAreaHighlighter slave_highlighter = null; //погонщик рабов
|
|
||||||
protected JToolBar tools;
|
protected JToolBar tools;
|
||||||
protected JLabel lObjectName;
|
protected JLabel lObjectName;
|
||||||
protected JButton bApplyObject;
|
protected JButton bApplyObject;
|
||||||
@@ -51,9 +45,11 @@ public abstract class ComparisonForm<T> {
|
|||||||
private boolean events_on = false;//относится только к мастеру, отвечает за скроллы.
|
private boolean events_on = false;//относится только к мастеру, отвечает за скроллы.
|
||||||
private int current_diff_line = -1;
|
private int current_diff_line = -1;
|
||||||
final String separator = "\u200B";
|
final String separator = "\u200B";
|
||||||
|
final char cseparator = '\u200B';
|
||||||
//невидимый пробел https://translated.turbopages.org/proxy_u/en-ru.ru.898e1daf-67e318c0-3fccff8a-74722d776562/https/stackoverflow.com/questions/17978720/invisible-characters-ascii
|
//невидимый пробел https://translated.turbopages.org/proxy_u/en-ru.ru.898e1daf-67e318c0-3fccff8a-74722d776562/https/stackoverflow.com/questions/17978720/invisible-characters-ascii
|
||||||
//--->>
|
//--->>
|
||||||
// protected Object ownScrollModel = null;
|
// protected Object ownScrollModel = null;
|
||||||
|
protected Vector<Pair<Integer, Integer>> diffs = new Vector<>();
|
||||||
//---<<
|
//---<<
|
||||||
public ComparisonForm(Class<T> t_in, ComparisonForm<T> slave_in) {
|
public ComparisonForm(Class<T> t_in, ComparisonForm<T> slave_in) {
|
||||||
//-
|
//-
|
||||||
@@ -75,7 +71,6 @@ public abstract class ComparisonForm<T> {
|
|||||||
if (isMaster()) {
|
if (isMaster()) {
|
||||||
//<editor-fold desc="синхронизация скроллов">
|
//<editor-fold desc="синхронизация скроллов">
|
||||||
slave.Scroll.getVerticalScrollBar().setModel(Scroll.getVerticalScrollBar().getModel());
|
slave.Scroll.getVerticalScrollBar().setModel(Scroll.getVerticalScrollBar().getModel());
|
||||||
slave_highlighter = (RSyntaxTextAreaHighlighter) slave.Body.getHighlighter();
|
|
||||||
//бяк быть не должно при условии что строк одинаковое количество. а это должно выполняться.
|
//бяк быть не должно при условии что строк одинаковое количество. а это должно выполняться.
|
||||||
Body.addCaretListener(e -> {
|
Body.addCaretListener(e -> {
|
||||||
if (events_on && isReady() && slave.isReady()) {
|
if (events_on && isReady() && slave.isReady()) {
|
||||||
@@ -153,6 +148,8 @@ public abstract class ComparisonForm<T> {
|
|||||||
//-----------------------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------------------
|
||||||
Body.setText("");
|
Body.setText("");
|
||||||
slave.Body.setText("");
|
slave.Body.setText("");
|
||||||
|
Body.getHighlighter().removeAllHighlights();
|
||||||
|
slave.Body.getHighlighter().removeAllHighlights();
|
||||||
int d = 0;
|
int d = 0;
|
||||||
getLines();
|
getLines();
|
||||||
slave.getLines();
|
slave.getLines();
|
||||||
@@ -170,7 +167,6 @@ public abstract class ComparisonForm<T> {
|
|||||||
List<DiffRow> rows = generator.generateDiffRows(
|
List<DiffRow> rows = generator.generateDiffRows(
|
||||||
visible_lines,
|
visible_lines,
|
||||||
slave.visible_lines);
|
slave.visible_lines);
|
||||||
|
|
||||||
for (DiffRow row : rows) {
|
for (DiffRow row : rows) {
|
||||||
t1.add(row.getOldLine());
|
t1.add(row.getOldLine());
|
||||||
t2.add(row.getNewLine());
|
t2.add(row.getNewLine());
|
||||||
@@ -180,32 +176,62 @@ public abstract class ComparisonForm<T> {
|
|||||||
Body.setCaretPosition(0);
|
Body.setCaretPosition(0);
|
||||||
slave.Body.setCaretPosition(0);
|
slave.Body.setCaretPosition(0);
|
||||||
//--
|
//--
|
||||||
Pattern master_pattern = Pattern.compile(separator + ".*" + separator);
|
fillDiffs();
|
||||||
Matcher master_matcher = master_pattern.matcher(Body.getText());
|
slave.fillDiffs();
|
||||||
while (master_matcher.find()) {
|
colorDiffs();
|
||||||
Body.getHighlighter().addHighlight(
|
slave.colorDiffs();
|
||||||
master_matcher.start(),
|
|
||||||
master_matcher.end(),
|
|
||||||
SPFEditor.RedTextPainter
|
|
||||||
);
|
|
||||||
}
|
|
||||||
Pattern slave_pattern = Pattern.compile(separator + ".*" + separator);
|
|
||||||
Matcher slave_matcher = slave_pattern.matcher(slave.Body.getText());
|
|
||||||
while (slave_matcher.find()) {
|
|
||||||
slave_highlighter.addHighlight(
|
|
||||||
slave_matcher.start(),
|
|
||||||
slave_matcher.end(),
|
|
||||||
SPFEditor.GreenTextPainter
|
|
||||||
);
|
|
||||||
}
|
|
||||||
events_on = true;
|
events_on = true;
|
||||||
}
|
}
|
||||||
|
public void fillDiffs() {
|
||||||
|
diffs.clear();
|
||||||
|
boolean flag = false;
|
||||||
|
char[] chars = Body.getText().toCharArray();
|
||||||
|
int dif_start=CommonConstants.Nan;
|
||||||
|
int dif_end=CommonConstants.Nan;
|
||||||
|
for (int i = 0; i < chars.length; ++i) {
|
||||||
|
char c = chars[i];
|
||||||
|
//--
|
||||||
|
if (flag) {
|
||||||
|
//различие
|
||||||
|
switch (c){
|
||||||
|
case cseparator:
|
||||||
|
//кончилось различие
|
||||||
|
dif_end =i;
|
||||||
|
flag=false;
|
||||||
|
diffs.add(new Pair<>(dif_start,dif_end));
|
||||||
|
dif_start=CommonConstants.Nan;
|
||||||
|
dif_end=CommonConstants.Nan;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
//поиск
|
||||||
|
switch (c) {
|
||||||
|
case cseparator:
|
||||||
|
//началось различие
|
||||||
|
dif_start =i;
|
||||||
|
flag=true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void colorDiffs() throws Exception{
|
||||||
|
Highlighter.HighlightPainter painter = isMaster()? SPFEditor.RedTextPainter: SPFEditor.GreenTextPainter;
|
||||||
|
for (Pair<Integer, Integer> diff: diffs){
|
||||||
|
Body.getHighlighter().addHighlight(diff.getKey(),diff.getValue(), painter);
|
||||||
|
}
|
||||||
|
}
|
||||||
public void Show() throws Exception {
|
public void Show() throws Exception {
|
||||||
events_on = false;
|
events_on = false;
|
||||||
current_diff_line = CommonConstants.Nan;
|
current_diff_line = CommonConstants.Nan;
|
||||||
//----------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------
|
||||||
Body.setText("");
|
Body.setText("");
|
||||||
slave.Body.setText("");
|
slave.Body.setText("");
|
||||||
|
Body.getHighlighter().removeAllHighlights();
|
||||||
|
slave.Body.getHighlighter().removeAllHighlights();
|
||||||
int d = 0;
|
int d = 0;
|
||||||
getLines();
|
getLines();
|
||||||
slave.getLines();
|
slave.getLines();
|
||||||
|
|||||||
Reference in New Issue
Block a user