@@ -104,11 +104,12 @@ except FileNotFoundError:
104104 version = "'Encryptext Travel Mode'"
105105
106106font_scale_factor = settings ["otherSettings" ]["fontScaleFactor" ]
107+ theme = settings ["otherSettings" ]["theme" ]
107108
108109"""
109110Custom Classes
110111"""
111- if settings [ "otherSettings" ][ " theme" ] == "light" :
112+ if theme == "light" :
112113 bg = "white"
113114 text = "black"
114115 code_bg = "#f8f8f8"
@@ -199,7 +200,7 @@ class TextLineNumbers(tk.Canvas):
199200 def __init__ (self , * args , ** kwargs ):
200201 tk .Canvas .__init__ (self , * args , ** kwargs )
201202 self .textwidget = None
202- if settings [ "otherSettings" ][ " theme" ] == "light" :
203+ if theme == "light" :
203204 self .configure (bg = "#f7f7f7" )
204205 else :
205206 self .configure (bg = "#1c1c1c" )
@@ -216,7 +217,7 @@ class TextLineNumbers(tk.Canvas):
216217 if dline is None : break
217218 y = dline [1 ]
218219 linenum = str (i ).split ("." )[0 ]
219- if settings [ "otherSettings" ][ " theme" ] == "light" :
220+ if theme == "light" :
220221 self .create_text (2 ,y ,anchor = "nw" , text = linenum , fill = "#000000" )
221222 else :
222223 self .create_text (2 ,y ,anchor = "nw" , text = linenum , fill = "#ffffff" )
@@ -310,7 +311,7 @@ class PreferenceWindow(tk.Toplevel):
310311 ttk .Separator (self .pref_window , orient = "horizontal" ).pack (side = "top" , fill = "x" , padx = 100 , pady = 10 )
311312
312313 # Theme selector
313- self .selected_theme = tk .StringVar (value = settings [ "otherSettings" ][ " theme" ] )
314+ self .selected_theme = tk .StringVar (value = theme )
314315 self .theme_label = WrappedLabel (self .pref_window , text = "Theme: " , font = (settings ["otherSettings" ]["fontStyle" ], int (round (11 * font_scale_factor ))))
315316 self .light_theme_val = ttk .Radiobutton (self .theme_label , text = "Light" , value = "light" , variable = self .selected_theme )
316317 self .dark_theme_val = ttk .Radiobutton (self .theme_label , text = "Dark" , value = "dark" , variable = self .selected_theme )
@@ -386,12 +387,12 @@ class PreferenceWindow(tk.Toplevel):
386387 global settings
387388
388389 # Save preferences that have been selected
389- settings ["maxRecentFiles" ] = self .selected_recent_files .get ()
390+ settings ["maxRecentFiles" ] = max ( 0 , min ( 20 , self .selected_recent_files .get ()) )
390391 settings ["otherSettings" ]["fontStyle" ] = self .selected_font_style .get ()
391- settings ["otherSettings" ]["fontScaleFactor" ] = self .selected_font_sf .get ()
392+ settings ["otherSettings" ]["fontScaleFactor" ] = max ( 0.5 , min ( 2 , self .selected_font_sf .get ()) )
392393 settings ["otherSettings" ]["theme" ] = self .selected_theme .get ()
393394 settings ["otherSettings" ]["autoSave" ] = self .selected_auto_save .get ()
394- settings ["otherSettings" ]["autoSaveInterval" ] = self .selected_auto_save_interval_val .get ()
395+ settings ["otherSettings" ]["autoSaveInterval" ] = max ( 1 , min ( 600 , self .selected_auto_save_interval_val .get ()) )
395396 settings ["otherSettings" ]["language" ] = self .language_val .get ()
396397 settings ["otherSettings" ]["showLineNumbers" ] = self .selected_show_line_no .get ()
397398 settings ["otherSettings" ]["wrapLines" ] = self .selected_wrap_line .get ()
@@ -438,7 +439,8 @@ class PreviewWindow(tk.Toplevel):
438439 if current_tab == - 1 :
439440 return None
440441
441- self .frame .load_html (markdown (textboxes [current_tab ].get ("1.0" , tk .END )))
442+ text = textboxes [current_tab ].get ("1.0" , tk .END )
443+ self .updateFrame (text )
442444 self .frame .pack (fill = "both" , expand = True )
443445
444446 def updateFrame (self , text : str ) -> None :
@@ -452,7 +454,7 @@ class PreviewWindow(tk.Toplevel):
452454Window Settings
453455"""
454456# Create the window and configure the background for theme changes
455- if settings [ "otherSettings" ][ " theme" ] == "light" :
457+ if theme == "light" :
456458 styles = ttk .Style (theme = "cosmo" )
457459else :
458460 styles = ttk .Style (theme = "darkly" )
@@ -1378,7 +1380,7 @@ def addNewTab(Event=None):
13781380
13791381 if settings ["otherSettings" ]["highlightActiveLine" ] == True :
13801382 # Adapted from https://stackoverflow.com/a/9720858
1381- if settings [ "otherSettings" ][ " theme" ] == "light" :
1383+ if theme == "light" :
13821384 textboxes [- 1 ].tag_configure ("current_line" , background = "#e9e9e9" )
13831385 else :
13841386 textboxes [- 1 ].tag_configure ("current_line" , background = "#262626" )
0 commit comments