mirror of
https://github.com/vishalxl/nostr_console.git
synced 2025-04-02 17:08:12 +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);
|
||||
if( valueOption != null) {
|
||||
if( valueOption >= 1 && valueOption <= menuOptions.length) {
|
||||
readjustAlignment(); // in case user has changed alignment
|
||||
return valueOption;
|
||||
}
|
||||
}
|
||||
@ -459,7 +460,6 @@ Future<void> channelMenuUI(Store node) async {
|
||||
//gDebug = 0;
|
||||
bool continueChatMenu = true;
|
||||
while(continueChatMenu) {
|
||||
readjustAlignment();
|
||||
int option = showMenu([ 'Show public channels', // 1
|
||||
'Enter a public channel', // 2
|
||||
'Go back to main menu'], // 3
|
||||
@ -620,8 +620,6 @@ Future<void> mainMenuUi(Store node) async {
|
||||
bool userContinue = true;
|
||||
while(userContinue) {
|
||||
|
||||
readjustAlignment();
|
||||
|
||||
await processNotifications(node); // this takes 300 ms
|
||||
|
||||
// the main menu
|
||||
|
@ -1,6 +1,7 @@
|
||||
import 'dart:ffi';
|
||||
import 'dart:io';
|
||||
import 'dart:convert';
|
||||
import 'dart:math';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:translator/translator.dart';
|
||||
import 'package:crypto/crypto.dart';
|
||||
@ -675,13 +676,31 @@ String rightShiftContent(String s, int numSpaces) {
|
||||
numCharsInCurLine = 0;
|
||||
} else {
|
||||
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 += spacesString;
|
||||
numCharsInCurLine = 0;
|
||||
}
|
||||
} else {
|
||||
newString += "\n";
|
||||
newString += spacesString;
|
||||
numCharsInCurLine = 0;
|
||||
}
|
||||
|
||||
newString += "\n";
|
||||
newString += spacesString;
|
||||
numCharsInCurLine = 0;
|
||||
}
|
||||
newString += s[i];
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user