Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
maelswarm committed Jan 20, 2018
1 parent 68f6005 commit ab0a955
Showing 1 changed file with 6 additions and 60 deletions.
66 changes: 6 additions & 60 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,6 @@ void downArrow(int enteredValue) {
--editingCursorPositionY;
i = 0;
while(newFileString[editingPageOffset] != '\n' && newFileString[editingPageOffset] != '\0' && i < winsize.ws_col) {
if (newFileString[editingPageOffset] == '\t') {
i+=3;
}
++editingPageOffset;
++i;
}
Expand All @@ -373,12 +370,7 @@ void downArrow(int enteredValue) {
printf("\033[%i;%iH", editingCursorPositionY, editingCursorPositionX);
return;
}

if (newFileString[newFileStrOffset] == '\t') {
i+=4;
} else {
++i;
}
++i;
++newFileStrOffset;
}

Expand All @@ -399,9 +391,6 @@ void downArrow(int enteredValue) {
i = 1;
int j = 0;
while(i < editingCursorPositionX && newFileString[newFileStrOffset] != '\0' && newFileString[newFileStrOffset] != '\n') {
if(newFileString[newFileStrOffset] == 9) {
i += 3;
}
++i;
++j;
++newFileStrOffset;
Expand All @@ -418,9 +407,6 @@ void downArrow(int enteredValue) {
if (q >= winsize.ws_col - 1) {
break;
}
if(newFileString[editingPageOffset+q] == 9) {
q+=3;
}
++q;
++p;
}
Expand Down Expand Up @@ -460,9 +446,6 @@ void upArrow(int enteredValue) {
int j = 0;
i = 1;
while(editingPageOffset - i > -1 && newFileString[editingPageOffset-i] != 10) {
if(newFileString[editingPageOffset - i] == 9) {
j+=3;
}
++j;
++i;
}
Expand All @@ -473,11 +456,7 @@ void upArrow(int enteredValue) {
printf("\033[%i;%iH", editingCursorPositionY, editingCursorPositionX);
return;
}
if (newFileString[newFileStrOffset] == '\t') {
i+=4;
} else {
++i;
}
++i;
--newFileStrOffset;
}
if(newFileString[newFileStrOffset] == '\n') {
Expand Down Expand Up @@ -534,9 +513,6 @@ void upArrow(int enteredValue) {
++i;
}
while(editingPageOffset - j > -1 && newFileString[editingPageOffset - j] != 10) {
if(newFileString[editingPageOffset - j] == 9) {
i+=3;
}
++j;
++i;
}
Expand All @@ -545,9 +521,6 @@ void upArrow(int enteredValue) {
++i;
}
while(editingPageOffset - j > -1 && newFileString[editingPageOffset - j] != 10) {
if(newFileString[editingPageOffset - j] == 9) {
i+=3;
}
++j;
++i;
}
Expand All @@ -573,13 +546,9 @@ void upArrow(int enteredValue) {
while(i < editingCursorPositionX) {
if(newFileString[editingPageOffset + j] == 10) {
break;
} else if(newFileString[editingPageOffset + j] == 9) {
i+=4;
++j;
} else {
++i;
++j;
}
++i;
++j;
}

editingCursorPositionX = i;
Expand Down Expand Up @@ -647,9 +616,6 @@ void rightArrow(int enteredValue) {
} else {
int i = 0;
while(newFileString[newFileStrOffset + i] != 10 && newFileString[newFileStrOffset + i] != '\0' && i<winsize.ws_col) {
if(newFileString[newFileStrOffset + i] == 9) {
i+=3;
}
++i;
++editingPageOffset;
}
Expand Down Expand Up @@ -700,9 +666,6 @@ void leftArrow(enteredValue) {
--editingPageOffset;
}
while(newFileString[editingPageOffset - j] != 10 && editingPageOffset - j > -2) {
if(newFileString[editingPageOffset - j] == 9) {
i+=3;
}
++i;
++j;
}
Expand Down Expand Up @@ -734,13 +697,8 @@ void leftArrow(enteredValue) {
int i = 1;
int cnt = 1;
while(newFileString[newFileStrOffset - i] != 10 && newFileStrOffset - i > -2) {
if(newFileString[newFileStrOffset - i] == 9) {
cnt += 4;
++i;
} else {
++cnt;
++i;
}
++cnt;
++i;
}
editingCursorPositionX = cnt;
refreshDisplay(UPDATE);
Expand All @@ -749,9 +707,6 @@ void leftArrow(enteredValue) {
--newFileStrOffset;
int i = 0;
while(newFileString[newFileStrOffset - i] != 10 && newFileStrOffset - i > -1) {
if(newFileString[newFileStrOffset - i] == 9) {
i+=3;
}
++i;
}
editingCursorPositionX = (i+1)%winsize.ws_col;
Expand All @@ -762,9 +717,6 @@ void leftArrow(enteredValue) {
if(editingCursorPositionX <= 1) {
int i = 0;
while(newFileString[newFileStrOffset - i] != 10 && newFileStrOffset - i > -1 && i < winsize.ws_col) {
if(newFileString[newFileStrOffset - i] == 9) {
i+=3;
}
++i;
}
--editingCursorPositionY;
Expand Down Expand Up @@ -1018,9 +970,6 @@ int main(int argc, char **argv) {
if(editingCursorPositionY <= 1) {
int i = 0;
while(newFileString[newFileStrOffset - i] != 10 && newFileStrOffset - i > -2 && i<winsize.ws_col) {
if(newFileString[newFileStrOffset - i] == 9) {
i+=3;
}
i++;
--editingPageOffset;
}
Expand All @@ -1034,9 +983,6 @@ int main(int argc, char **argv) {
removeChar(newFileString, newFileStrOffset);
int i = 0;
while(newFileString[newFileStrOffset - i] != 10 && newFileStrOffset - i > -2 && i<winsize.ws_col) {
if(newFileString[newFileStrOffset - i] == 9) {
i+=3;
}
i++;
}
editingCursorPositionX = i;
Expand Down

0 comments on commit ab0a955

Please sign in to comment.