mirror of
https://github.com/vishalxl/nostr_console.git
synced 2025-06-06 21:20:09 +02:00
improved text breaks when printing
and moved realignment of screen into menu for better results
This commit is contained in:
parent
b0af54f353
commit
dd717a289b
@ -191,6 +191,7 @@ int showMenu(List<String> menuOptions, String menuName) {
|
|||||||
int? valueOption = int.tryParse(userOption);
|
int? valueOption = int.tryParse(userOption);
|
||||||
if( valueOption != null) {
|
if( valueOption != null) {
|
||||||
if( valueOption >= 1 && valueOption <= menuOptions.length) {
|
if( valueOption >= 1 && valueOption <= menuOptions.length) {
|
||||||
|
readjustAlignment(); // in case user has changed alignment
|
||||||
return valueOption;
|
return valueOption;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -459,7 +460,6 @@ 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
|
||||||
@ -620,8 +620,6 @@ Future<void> mainMenuUi(Store node) async {
|
|||||||
bool userContinue = true;
|
bool userContinue = true;
|
||||||
while(userContinue) {
|
while(userContinue) {
|
||||||
|
|
||||||
readjustAlignment();
|
|
||||||
|
|
||||||
await processNotifications(node); // this takes 300 ms
|
await processNotifications(node); // this takes 300 ms
|
||||||
|
|
||||||
// the main menu
|
// the main menu
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import 'dart:ffi';
|
import 'dart:ffi';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
import 'dart:math';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:translator/translator.dart';
|
import 'package:translator/translator.dart';
|
||||||
import 'package:crypto/crypto.dart';
|
import 'package:crypto/crypto.dart';
|
||||||
@ -675,14 +676,32 @@ String rightShiftContent(String s, int numSpaces) {
|
|||||||
numCharsInCurLine = 0;
|
numCharsInCurLine = 0;
|
||||||
} else {
|
} else {
|
||||||
if( numCharsInCurLine >= (gTextWidth - numSpaces)) {
|
if( numCharsInCurLine >= (gTextWidth - numSpaces)) {
|
||||||
if( i > 1 && (!isWordSeparater(s[i-1]) && !isWordSeparater(s[i])) ) {
|
if( i > 1 && !isWordSeparater(s[i])) {
|
||||||
|
// go back in output string and readjust it if needed
|
||||||
|
const int lookForSpace = 6;
|
||||||
|
bool foundSpace = false;
|
||||||
|
for(int j = 0; j < min(newString.length, lookForSpace); j++) {
|
||||||
|
if( newString[newString.length-1-j] == " ") {
|
||||||
|
foundSpace = true;
|
||||||
|
String charsInNextLine = "";
|
||||||
|
charsInNextLine = newString.substring(newString.length-j, newString.length);
|
||||||
|
String temp = newString.substring(0, newString.length-j) + "\n" + spacesString + charsInNextLine;
|
||||||
|
newString = temp;
|
||||||
|
numCharsInCurLine = charsInNextLine.length;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if(!foundSpace) {
|
||||||
newString += "\n";
|
newString += "\n";
|
||||||
newString += spacesString;
|
newString += spacesString;
|
||||||
numCharsInCurLine = 0;
|
numCharsInCurLine = 0;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
newString += "\n";
|
||||||
|
newString += spacesString;
|
||||||
|
numCharsInCurLine = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
newString += s[i];
|
newString += s[i];
|
||||||
}
|
}
|
||||||
numCharsInCurLine++;
|
numCharsInCurLine++;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user