mirror of
https://github.com/vishalxl/nostr_console.git
synced 2025-04-01 00:18:21 +02:00
avoided two exceptions related to terminalcolumns
and to writing wrong delete event string
This commit is contained in:
parent
60e2d4bf1b
commit
3f89e0b00f
@ -114,11 +114,17 @@ Future<void> main(List<String> arguments) async {
|
||||
}
|
||||
}
|
||||
try {
|
||||
|
||||
var terminalColumns = gDefaultTextWidth;
|
||||
|
||||
if( stdout.hasTerminal )
|
||||
terminalColumns = stdout.terminalColumns;
|
||||
|
||||
// can be computed only after textWidth has been found
|
||||
if( gTextWidth > stdout.terminalColumns) {
|
||||
gTextWidth = stdout.terminalColumns - 5;
|
||||
if( gTextWidth > terminalColumns) {
|
||||
gTextWidth = terminalColumns - 5;
|
||||
}
|
||||
gNumLeftMarginSpaces = (stdout.terminalColumns - gTextWidth )~/2;
|
||||
gNumLeftMarginSpaces = (terminalColumns - gTextWidth )~/2;
|
||||
} on StdoutException catch (e) {
|
||||
print("Cannot find terminal size. Left aligning by default.");
|
||||
if( gDebug > 0) log.info("${e.message}");
|
||||
|
@ -173,10 +173,15 @@ void reAdjustAlignment() {
|
||||
// align the text again in case the window size has been changed
|
||||
if( gAlignment == "center") {
|
||||
try {
|
||||
if( gTextWidth > stdout.terminalColumns) {
|
||||
gTextWidth = stdout.terminalColumns - 5;
|
||||
var terminalColumns = gDefaultTextWidth;
|
||||
|
||||
if( stdout.hasTerminal )
|
||||
terminalColumns = stdout.terminalColumns;
|
||||
|
||||
if( gTextWidth > terminalColumns) {
|
||||
gTextWidth = terminalColumns - 5;
|
||||
}
|
||||
gNumLeftMarginSpaces = (stdout.terminalColumns - gTextWidth )~/2;
|
||||
gNumLeftMarginSpaces = (terminalColumns - gTextWidth )~/2;
|
||||
} on StdoutException catch (e) {
|
||||
print("Terminal information not available");
|
||||
if( gDebug>0) print("${e.message}");
|
||||
|
@ -480,6 +480,7 @@ class Event {
|
||||
} on Exception catch(e) {
|
||||
if( gDebug> 0) {
|
||||
print("Could not create event. returning dummy event. $e");
|
||||
print("problem str: $d\n");
|
||||
}
|
||||
return Event("","",EventData("non","", 0, 0, "", [], [], [], [[]], {}), [relay], "[json]", fromFile);
|
||||
}
|
||||
|
@ -340,8 +340,15 @@ String intro =
|
||||
|
||||
List<String> lines = intro.split("\n");
|
||||
|
||||
var terminalColumns = gDefaultTextWidth;
|
||||
|
||||
if( stdout.hasTerminal )
|
||||
terminalColumns = stdout.terminalColumns;
|
||||
|
||||
|
||||
//print(gCommentColor);
|
||||
lines.forEach((line) {print(line.length > stdout.terminalColumns ? line.substring(0, stdout.terminalColumns) : line );});
|
||||
|
||||
lines.forEach((line) {print(line.length > terminalColumns ? line.substring(0, terminalColumns) : line );});
|
||||
//print(gColorEndMarker);
|
||||
|
||||
//print("\n$intro\n");
|
||||
|
@ -1502,7 +1502,7 @@ class Store {
|
||||
deletedEvent.eventData.content = gDeletedEventMessage;
|
||||
deletedEvent.eventData.evaluatedContent = "";
|
||||
EventData ed = deletedEvent.eventData;
|
||||
deletedEvent.originalJson = '["EVENT","none",{"id":${ed.id},"pubkey":${ed.pubkey},"createdAt":${ed.createdAt},"kind":1,"tags":[],"sig":"invalid","comment":"deleted"}]';
|
||||
deletedEvent.originalJson = '["EVENT","deleted",{"id":"${ed.id}","pubkey":"${ed.pubkey}","createdAt":${ed.createdAt},"kind":1,"tags":[],"sig":"invalid","comment":"deleted"}]';
|
||||
deletedEventIds.add( deletedEvent.eventData.id);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user