mirror of
https://github.com/vishalxl/nostr_console.git
synced 2025-06-21 22:31:06 +02:00
improved channel message printing and related
This commit is contained in:
parent
42d804a9b6
commit
f9eec2731d
@ -459,6 +459,7 @@ Future<void> channelMenuUI(Store node) async {
|
|||||||
//gDebug = 0;
|
//gDebug = 0;
|
||||||
bool continueChatMenu = true;
|
bool continueChatMenu = true;
|
||||||
while(continueChatMenu) {
|
while(continueChatMenu) {
|
||||||
|
readjustAlignment();
|
||||||
int option = showMenu([ 'Show public channels', // 1
|
int option = showMenu([ 'Show public channels', // 1
|
||||||
'Enter a public channel', // 2
|
'Enter a public channel', // 2
|
||||||
'Go back to main menu'], // 3
|
'Go back to main menu'], // 3
|
||||||
@ -480,6 +481,7 @@ Future<void> channelMenuUI(Store node) async {
|
|||||||
}
|
}
|
||||||
int pageNum = 1;
|
int pageNum = 1;
|
||||||
while(showChannelOption) {
|
while(showChannelOption) {
|
||||||
|
readjustAlignment();
|
||||||
String fullChannelId = node.showChannel(channelId, pageNum);
|
String fullChannelId = node.showChannel(channelId, pageNum);
|
||||||
if( fullChannelId == "") {
|
if( fullChannelId == "") {
|
||||||
print("Could not find the given channel.");
|
print("Could not find the given channel.");
|
||||||
@ -618,19 +620,7 @@ Future<void> mainMenuUi(Store node) async {
|
|||||||
bool userContinue = true;
|
bool userContinue = true;
|
||||||
while(userContinue) {
|
while(userContinue) {
|
||||||
|
|
||||||
// align the text again in case the window size has been changed
|
readjustAlignment();
|
||||||
if( gAlignment == "center") {
|
|
||||||
try {
|
|
||||||
if( gTextWidth > stdout.terminalColumns) {
|
|
||||||
gTextWidth = stdout.terminalColumns - 5;
|
|
||||||
}
|
|
||||||
gNumLeftMarginSpaces = (stdout.terminalColumns - gTextWidth )~/2;
|
|
||||||
} on StdoutException catch (e) {
|
|
||||||
print("Terminal information not available");
|
|
||||||
if( gDebug>0) print("${e.message}");
|
|
||||||
gNumLeftMarginSpaces = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
await processNotifications(node); // this takes 300 ms
|
await processNotifications(node); // this takes 300 ms
|
||||||
|
|
||||||
|
@ -294,6 +294,37 @@ class EventData {
|
|||||||
return '"${content.substring(0, len)}..." - ${getAuthorName(pubkey)}';
|
return '"${content.substring(0, len)}..." - ${getAuthorName(pubkey)}';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String getStrForChannel(int depth) {
|
||||||
|
String strToPrint = "";
|
||||||
|
String name = getAuthorName(pubkey);
|
||||||
|
String strDate = getPrintableDate(createdAt);
|
||||||
|
String tempEvaluatedContent = evaluatedContent;
|
||||||
|
String tempContent = content;
|
||||||
|
|
||||||
|
if( isHidden) {
|
||||||
|
name = "<hidden>";
|
||||||
|
strDate = "<hidden>";
|
||||||
|
tempEvaluatedContent = tempContent = "<You have hidden this post>";
|
||||||
|
}
|
||||||
|
|
||||||
|
// delete supercedes hidden
|
||||||
|
if( isDeleted) {
|
||||||
|
name = "<deleted>";
|
||||||
|
strDate = "<deleted>";
|
||||||
|
tempEvaluatedContent = tempContent = content; // content would be changed so show that
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
String nameToPrint = name.padLeft(gSpacesPerDepth * 2).substring(0, gSpacesPerDepth * 2);
|
||||||
|
String dateToPrint = strDate.padLeft(gSpacesPerDepth * 2).substring(0, gSpacesPerDepth * 2);
|
||||||
|
strToPrint = "${getDepthSpaces(depth)} $dateToPrint$nameToPrint: ";
|
||||||
|
int contentDepth = depth + 4 + 1;
|
||||||
|
String contentShifted = rightShiftContent(tempEvaluatedContent==""?tempContent: tempEvaluatedContent, gSpacesPerDepth * contentDepth);
|
||||||
|
strToPrint += contentShifted;
|
||||||
|
return strToPrint;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// looks up global map of reactions, if this event has any reactions, and then prints the reactions
|
// looks up global map of reactions, if this event has any reactions, and then prints the reactions
|
||||||
// in appropriate color( in case one is a notification, which is stored in member variable)
|
// in appropriate color( in case one is a notification, which is stored in member variable)
|
||||||
String getReactionStr(int depth) {
|
String getReactionStr(int depth) {
|
||||||
@ -868,3 +899,18 @@ Set<Event> readEventsFromFile(String filename) {
|
|||||||
return events;
|
return events;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
gNumLeftMarginSpaces = (stdout.terminalColumns - gTextWidth )~/2;
|
||||||
|
} on StdoutException catch (e) {
|
||||||
|
print("Terminal information not available");
|
||||||
|
if( gDebug>0) print("${e.message}");
|
||||||
|
gNumLeftMarginSpaces = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -112,7 +112,7 @@ const int gMaxDifficultyAllowed = 24;
|
|||||||
int gDifficulty = 0;
|
int gDifficulty = 0;
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////// channel related settings
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////// channel related settings
|
||||||
const int gNumChannelMessagesToShow = 15;
|
const int gNumChannelMessagesToShow = 25;
|
||||||
const int gMaxChannelPagesDisplayed = 50;
|
const int gMaxChannelPagesDisplayed = 50;
|
||||||
|
|
||||||
|
|
||||||
|
@ -43,8 +43,8 @@ class ScrollableMessages {
|
|||||||
String eId = messageIds[i];
|
String eId = messageIds[i];
|
||||||
Event? e = tempChildEventsMap[eId]?.event;
|
Event? e = tempChildEventsMap[eId]?.event;
|
||||||
if( e!= null) {
|
if( e!= null) {
|
||||||
e.printEvent(0);
|
print(e.eventData.getStrForChannel(0));
|
||||||
print("");
|
//print("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user