@@ -65,7 +65,7 @@ static void Main(string[] args)
6565
6666 Tuple = MenuLoop ( Content , BoardDimensions , true ) ;
6767
68- if ( BadWords . BadWords . list . Any ( Tuple . Item2 . Contains ) ) {
68+ if ( BadWords . BadWords . list . Any ( Tuple . Item2 . ToLower ( ) . Contains ) ) {
6969 Console . WriteLine ( "bad Word Found, Redo Step (wait a sec)" ) ;
7070 System . Threading . Thread . Sleep ( 3000 ) ;
7171 goto BadNameUsername ;
@@ -149,6 +149,7 @@ public static void PublicChat(User.User CurrentUser) {
149149 bool ChooseChatLoop = true ;
150150
151151 string [ ] var = Admin . Read . Chats . Public ( ) ;
152+ Array . Sort ( var ) ;
152153
153154 int Multiplyer = 0 ;
154155 int Step = BoardDimensions . Item2 - 6 ;
@@ -179,6 +180,7 @@ public static void PublicChat(User.User CurrentUser) {
179180 }
180181
181182 var = Admin . Read . Chats . Public ( ) ;
183+ Array . Sort ( var ) ;
182184 Multiplyer = 0 ;
183185
184186 while ( ! TextListener . GetESCPressed ( ) && ( Tuple . Item1 == Step - 1 || Tuple . Item1 == Step || Tuple . Item1 == Step + 1 ) ) {
@@ -219,12 +221,14 @@ public static void PublicChatLoop(string SelectedChat, User.User CurrentUser) {
219221 Tuple < int , int > BoardDimensions = CurrentUser . Read_User_BoardSettings ( ) ;
220222 DMSExtras . DMSExtras . TextListener TextListener = new DMSExtras . DMSExtras . TextListener ( ) ;
221223 DMSExtras . DMSExtras . ChatListener ChatListener = new DMSExtras . DMSExtras . ChatListener ( ) ;
224+ bool UpdateBoard = false ;
225+ int Pointer = 0 ;
222226
223227 string TypedText = " " ;
224228
225229 Thread threadChat = new Thread ( ( ) =>
226230 {
227- ChatListener . StartListening ( @"chatsPublic\" + SelectedChat ) ;
231+ ChatListener . StartListening ( @"chatsPublic\" + SelectedChat + ".txt" ) ;
228232 } ) ;
229233
230234 threadChat . Start ( ) ;
@@ -246,7 +250,7 @@ public static void PublicChatLoop(string SelectedChat, User.User CurrentUser) {
246250
247251 if ( TextListener . GetEnterPressed ( ) && ! string . IsNullOrEmpty ( TypedText ) ) {
248252
249- if ( BadWords . BadWords . list . Any ( TypedText . Contains ) ) {
253+ if ( BadWords . BadWords . list . Any ( TypedText . ToLower ( ) . Contains ) ) {
250254 Console . WriteLine ( "bad Word Found, Message not Sent" ) ;
251255 System . Threading . Thread . Sleep ( 1000 ) ;
252256 TextListener . StopListening ( ) ;
@@ -262,33 +266,36 @@ public static void PublicChatLoop(string SelectedChat, User.User CurrentUser) {
262266
263267 TextListener . StopListening ( ) ;
264268 TextListener . SetTypedText ( "" ) ;
269+ TextListener . SetPointer ( 0 ) ;
265270 TextListener . SetEnterPressed ( false ) ;
266271 TextListener . StartListening ( ) ;
267272 }
268273 }
269274
270275 if ( TypedText != TextListener . GetTypedText ( ) ) {
271-
272- // Console.WriteLine("text start");
273-
274276 TypedText = TextListener . GetTypedText ( ) ;
277+ UpdateBoard = true ;
278+ }
275279
276- User . User . Display . Content ( ChatMessages , BoardDimensions , TypedText , true , SelectedChat ) ;
277- // Console.WriteLine("text end");
278-
280+ if ( Pointer != TextListener . GetPointer ( ) ) {
281+ if ( TextListener . GetPointer ( ) < 0 ) {
282+ TextListener . StopListening ( ) ;
283+ TextListener . SetPointer ( 0 ) ;
284+ TextListener . StartListening ( ) ;
285+ }
286+ UpdateBoard = true ;
287+ Pointer = TextListener . GetPointer ( ) ;
279288 }
280289
281290 if ( ! ChatMessages . SequenceEqual ( ChatListener . GetChatContent ( ) ) ) {
282-
283- // Console.WriteLine("chat start");
284-
285291 ChatMessages = ChatListener . GetChatContent ( ) ;
292+ UpdateBoard = true ;
293+ }
286294
287- User . User . Display . Content ( ChatMessages , BoardDimensions , TypedText , true , SelectedChat ) ;
288- // Console.WriteLine("chat end" );
289-
295+ if ( UpdateBoard ) {
296+ User . User . Display . Content ( ChatMessages , BoardDimensions , TypedText , true , SelectedChat , Pointer ) ;
297+ UpdateBoard = false ;
290298 }
291- // Console.WriteLine("end");
292299 }
293300
294301
@@ -312,6 +319,7 @@ public static void PrivateChat(User.User CurrentUser) {
312319 bool ChooseChatLoop = true ;
313320
314321 string [ ] var = CurrentUser . Read_Chats_Allowed ( @"chats\" ) ;
322+ Array . Sort ( var ) ;
315323
316324 int Multiplyer = 0 ;
317325 int Step = BoardDimensions . Item2 - 6 ;
@@ -342,6 +350,7 @@ public static void PrivateChat(User.User CurrentUser) {
342350 }
343351
344352 var = Admin . Read . Users . All ( ) ;
353+ Array . Sort ( var ) ;
345354 Multiplyer = 0 ;
346355
347356 while ( ! TextListener . GetESCPressed ( ) && ( Tuple . Item1 == Step - 1 || Tuple . Item1 == Step || Tuple . Item1 == Step + 1 ) ) {
@@ -369,6 +378,11 @@ public static void PrivateChat(User.User CurrentUser) {
369378 }
370379 }
371380 if ( ! TextListener . GetESCPressed ( ) ) {
381+ if ( DisplayedChats [ Tuple . Item1 ] == "BugReport" ) {
382+ Console . WriteLine ( "submit bugs here, https://github.com/hacktheegg/EncryptedDMSystem/issues/new/choose" ) ;
383+ Console . ReadKey ( ) ;
384+ Console . ReadKey ( ) ;
385+ }
372386 string SelectedChat = DisplayedChats [ Tuple . Item1 ] ;
373387 string OtherUser = SelectedChat ;
374388 SelectedChat = CurrentUser . Read_Messages_FileName ( SelectedChat ) ;
@@ -429,12 +443,14 @@ public static Tuple<int, string> MenuLoop(string[] Content, Tuple<int,int> Board
429443 public static void PrivateChatLoop ( string SelectedChat , Tuple < int , int > BoardDimensions , User . User CurrentUser , Tuple < string , string > SymmetricKey , string OtherUser ) {
430444 DMSExtras . DMSExtras . TextListener TextListener = new DMSExtras . DMSExtras . TextListener ( ) ;
431445 DMSExtras . DMSExtras . ChatListener ChatListener = new DMSExtras . DMSExtras . ChatListener ( ) ;
446+ bool UpdateBoard = false ;
447+ int Pointer = 0 ;
432448
433449 string TypedText = " " ;
434450
435451 Thread threadChat = new Thread ( ( ) =>
436452 {
437- ChatListener . StartListening ( @"chats\" + SelectedChat ) ;
453+ ChatListener . StartListening ( @"chats\" + SelectedChat + ".txt" ) ;
438454 } ) ;
439455
440456 threadChat . Start ( ) ;
@@ -458,7 +474,7 @@ public static void PrivateChatLoop(string SelectedChat, Tuple<int, int> BoardDim
458474
459475 if ( TextListener . GetEnterPressed ( ) && ! string . IsNullOrEmpty ( TypedText ) ) {
460476
461- if ( BadWords . BadWords . list . Any ( TypedText . Contains ) ) {
477+ if ( BadWords . BadWords . list . Any ( TypedText . ToLower ( ) . Contains ) ) {
462478 Console . WriteLine ( "bad Word Found, Message not Sent" ) ;
463479 System . Threading . Thread . Sleep ( 1000 ) ;
464480 TextListener . StopListening ( ) ;
@@ -469,34 +485,38 @@ public static void PrivateChatLoop(string SelectedChat, Tuple<int, int> BoardDim
469485
470486 TextListener . StopListening ( ) ;
471487 TextListener . SetTypedText ( "" ) ;
488+ TextListener . SetPointer ( 0 ) ;
472489 TextListener . SetEnterPressed ( false ) ;
473490 TextListener . StartListening ( ) ;
474491 }
475492 }
476493
477494 if ( TypedText != TextListener . GetTypedText ( ) ) {
478-
479- // Console.WriteLine("text start");
480-
481495 TypedText = TextListener . GetTypedText ( ) ;
496+ UpdateBoard = true ;
497+ }
482498
483- User . User . Display . Content ( DecryptedMessages , BoardDimensions , TypedText , true , OtherUser ) ;
484- // Console.WriteLine("text end");
485-
499+ if ( Pointer != TextListener . GetPointer ( ) ) {
500+ if ( TextListener . GetPointer ( ) < 0 ) {
501+ TextListener . StopListening ( ) ;
502+ TextListener . SetPointer ( 0 ) ;
503+ TextListener . StartListening ( ) ;
504+ }
505+ UpdateBoard = true ;
506+ Pointer = TextListener . GetPointer ( ) ;
486507 }
487508
488509 if ( ! ChatMessages . SequenceEqual ( ChatListener . GetChatContent ( ) ) ) {
489-
490- // Console.WriteLine("chat start");
491-
492510 ChatMessages = ChatListener . GetChatContent ( ) ;
493511 DecryptedMessages = CurrentUser . Read_Messages_Chat ( ChatMessages ) ;
512+ UpdateBoard = true ;
494513
495- User . User . Display . Content ( DecryptedMessages , BoardDimensions , TypedText , true , OtherUser ) ;
496- // Console.WriteLine("chat end");
514+ }
497515
516+ if ( UpdateBoard ) {
517+ User . User . Display . Content ( DecryptedMessages , BoardDimensions , TypedText , true , OtherUser , Pointer ) ;
518+ UpdateBoard = false ;
498519 }
499- // Console.WriteLine("end");
500520 }
501521 TextListener . StopListening ( ) ;
502522 }
0 commit comments