Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
346 additions
and
275 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,36 @@ | ||
String stringReplaceAll(String string, String substring, String replacer) { | ||
int index = string.indexOf(substring); | ||
if (index == -1) { | ||
return string; | ||
} | ||
int index = string.indexOf(substring); | ||
if (index == -1) { | ||
return string; | ||
} | ||
|
||
final substringLength = substring.length; | ||
int endIndex = 0; | ||
String returnValue = ''; | ||
do { | ||
returnValue += string.substring(endIndex, index) + substring + replacer; | ||
endIndex = index + substringLength; | ||
index = string.indexOf(substring, endIndex); | ||
} while (index != -1); | ||
final substringLength = substring.length; | ||
int endIndex = 0; | ||
String returnValue = ''; | ||
do { | ||
returnValue += string.substring(endIndex, index) + substring + replacer; | ||
endIndex = index + substringLength; | ||
index = string.indexOf(substring, endIndex); | ||
} while (index != -1); | ||
|
||
returnValue += string.substring(endIndex); | ||
return returnValue; | ||
returnValue += string.substring(endIndex); | ||
return returnValue; | ||
} | ||
|
||
String stringEncaseCRLFWithFirstIndex(String string, String prefix, String suffix, int index) { | ||
int endIndex = 0; | ||
String returnValue = ''; | ||
do { | ||
final gotCR = string[index - 1] == '\r'; | ||
returnValue += string.substring(endIndex, (gotCR ? index - 1 : index)) + prefix + (gotCR ? '\r\n' : '\n') + suffix; | ||
endIndex = index + 1; | ||
index = string.indexOf('\n', endIndex); | ||
} while (index != -1); | ||
String stringEncaseCRLFWithFirstIndex( | ||
String string, String prefix, String suffix, int index) { | ||
int endIndex = 0; | ||
String returnValue = ''; | ||
do { | ||
final gotCR = string[index - 1] == '\r'; | ||
returnValue += string.substring(endIndex, (gotCR ? index - 1 : index)) + | ||
prefix + | ||
(gotCR ? '\r\n' : '\n') + | ||
suffix; | ||
endIndex = index + 1; | ||
index = string.indexOf('\n', endIndex); | ||
} while (index != -1); | ||
|
||
returnValue += string.substring(endIndex); | ||
return returnValue; | ||
} | ||
returnValue += string.substring(endIndex); | ||
return returnValue; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
import 'package:ansi_regex/ansi_regex.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
} | ||
void main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import 'package:ansi_regex/ansi_regex.dart'; | ||
|
||
/// | ||
/// | ||
/// Strip [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) from a [text] | ||
/// | ||
/// Use ansiRegex to match ANSI escape codes | ||
String stripAnsi(String text) { | ||
return text.replaceAll(ansiRegex(), ''); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
|
||
import 'src/ansi_wrap.dart'; | ||
|
||
/// For each newline, wrap separately | ||
String wrapAnsi(String string, int columns, { | ||
String wrapAnsi( | ||
String string, | ||
int columns, { | ||
bool? trim, | ||
bool? wordWrap, | ||
bool hard = false, | ||
}) { | ||
return string | ||
.replaceAll(RegExp('\r\n'), '\n') | ||
.split('\n') | ||
.map((line) => wrap(line, columns, trim: trim, wordWrap: wordWrap, hard: hard)) | ||
.join('\n'); | ||
return string | ||
.replaceAll(RegExp('\r\n'), '\n') | ||
.split('\n') | ||
.map((line) => | ||
wrap(line, columns, trim: trim, wordWrap: wordWrap, hard: hard)) | ||
.join('\n'); | ||
} |
Oops, something went wrong.