Commit 5ad27023 authored by Aayush's avatar Aayush

fixed bugs in ascii_art->pd

parent b38b0126
Pipeline #1643 failed with stage
in 0 seconds
......@@ -279,8 +279,9 @@
"canvas": {
"paste_clipboard_prompt": "Warnung: Sie sind dabei, Pd-Code einzufügen, der außerhalb von Pd erstellt wurde. Möchten Sie fortfahren?",
"ascii_art": {
"close": "Close Button",
"close_tt": "close ascii_art text area"
"close": "Close",
"close_tt": "close ascii_art text area",
"placeholder": "write your ascii_art here"
},
"save_dialog": {
"prompt": "Speichern der Änderungen in",
......
......@@ -278,8 +278,9 @@
"canvas": {
"paste_clipboard_prompt": "Warning: you are about to paste Pd code that came from somewhere outside of Pd. Do you want to continue?",
"ascii_art": {
"close": "Close Button",
"close_tt": "close ascii_art text area"
"close": "Close",
"close_tt": "close ascii_art text area",
"placeholder": "write your ascii_art here"
},
"save_dialog": {
"prompt": "Do you want to save the changes you made in",
......
......@@ -164,15 +164,13 @@ function parse_ascii_art(ascii_art) {
}
}
}
// Finding the connection's end points
for (i = 0 ; i < row ; i++) {
for (i = 0 ; i < string_array.length ; i++) {
for (j = 0 ; j < string_array[i].length ; j++) {
// visited_array to travel a connection path only once
var temp = string_array[i][j],
flag = 1,
end_index;
if (visited_array[i][j] == 0) {
switch(temp) {
case "|": start_index = new INDEX(i-1, j);
......@@ -196,8 +194,11 @@ function parse_ascii_art(ascii_art) {
// as a connection starting with X will
// be a single element connection
case "X": start_index = new INDEX(i, j);
end_index = new INDEX(i, j);
case "X": start_index = new INDEX(i, j+1);
end_index = new INDEX(i+1, j-1);
connections_array.push({index1:start_index, index2:end_index});
start_index = new INDEX(i, j-1);
end_index = new INDEX(i+1, j+1);
visited_array[i][j] = 1;
break;
default : flag = 0;
......@@ -213,7 +214,6 @@ function parse_ascii_art(ascii_art) {
}
}
//Finding the mapping between connections and Objects/Messages
for (i = 0 ; i< connections_array.length ; i++) {
var start_index = connections_array[i].index1,
......@@ -224,17 +224,16 @@ function parse_ascii_art(ascii_art) {
outlet_object_index=0,
start_point = 0,
end_point = 0,
state_flag = 0;
state_flag=0;
for (j = 0 ; j < obj_msg_array.length ; j++) {
var start = obj_msg_array[j].index1,
end = obj_msg_array[j].index2;
if ( start_index.x == end.x ) {
if ( start_index.x == end.x ) {
if ( Math.min( Math.abs(start_index.y - start.y) ,
Math.abs(start_index.y - end.y) ) < max_distance1 ) {
outlet_object_index=j;
max_distance1 = Math.abs(start_index.y - start.y);
max_distance1 = Math.min( Math.abs(start_index.y - start.y) ,
Math.abs(start_index.y - end.y) );
state_flag= state_flag+ 1;
if ( Math.abs(start_index.y - start.y) < Math.abs(start_index.y - end.y) ) {
start_point = 0;
......@@ -244,12 +243,12 @@ function parse_ascii_art(ascii_art) {
}
}
if ( end_index.x == start.x ){
if ( Math.abs(end_index.x - start.x)<=1 ) {
if ( Math.min( Math.abs(end_index.y - start.y) ,
Math.abs(end_index.y - end.y) ) < max_distance2 ) {
inlet_object_index=j;
max_distance2 = Math.abs(end_index.y - end.y);
max_distance2 = Math.min( Math.abs(end_index.y - start.y) ,
Math.abs(end_index.y - end.y) );
state_flag= state_flag+ 1;
if ( Math.abs(start_index.y - start.y) < Math.abs(start_index.y - end.y) ) {
end_point = 0;
......@@ -258,10 +257,8 @@ function parse_ascii_art(ascii_art) {
}
}
}
}
if (state_flag== 2)
if (state_flag>= 2)
{
state= "valid";
} else {
......@@ -309,6 +306,6 @@ function parse_ascii_art(ascii_art) {
var parser_data = {pd_message:pd_message,
state:state};
return parser_data;
}
};
exports.parse_ascii_art = parse_ascii_art;
......@@ -53,7 +53,9 @@
</div>
<div id="ascii_art" style="display:none;">
<textarea id="ascii_art_text_area"
rows="10" cols="25">write your ascii art here</textarea>
rows="10" cols="25"
data-i18n="canvas.ascii_art.placeholder">
</textarea>
<br/>
<p id="ascii_art_state">State:partial</p>
<button type="button"
......
......@@ -1613,6 +1613,7 @@ function nw_create_patch_window_menus(gui, w, name) {
if (display_state === "none") {
ascii_art.style.setProperty("display", "inline");
ascii_art_text_area.focus();
ascii_art_text_area.select();
canvas_events.ascii_art();
} else {
ascii_art_text_area.value = "write your ascii art here";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment