From b57aaf83e1a4ce252ba0ccd93aa52c047f83d628 Mon Sep 17 00:00:00 2001 From: Gregory John Casamento Date: Thu, 15 Apr 2021 00:38:06 -0400 Subject: [PATCH] Add indentation prefs --- GNUmakefile | 3 +- .../Indentation/PCIndentationPrefs.h | 1 + .../Indentation/PCIndentationPrefs.m | 88 ++++++++++++++++-- .../IndentationPrefs.gorm/objects.gorm | Bin 8337 -> 8337 bytes 4 files changed, 83 insertions(+), 9 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 8a8afa0..7d8bb55 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -94,7 +94,8 @@ Modules/Debuggers/ProjectCenter/ProjectCenter.debugger \ Modules/Preferences/Build/Build.preferences \ Modules/Preferences/Saving/Saving.preferences \ Modules/Preferences/Misc/Misc.preferences \ -Modules/Preferences/EditorFSC/EditorFSC.preferences +Modules/Preferences/EditorFSC/EditorFSC.preferences \ +Modules/Preferences/Indentation/Indentation.preferences # # Localization diff --git a/Modules/Preferences/Indentation/PCIndentationPrefs.h b/Modules/Preferences/Indentation/PCIndentationPrefs.h index bc4796d..7b9b59b 100644 --- a/Modules/Preferences/Indentation/PCIndentationPrefs.h +++ b/Modules/Preferences/Indentation/PCIndentationPrefs.h @@ -22,6 +22,7 @@ // You should have received a copy of the GNU General Public // License along with this library; if not, write to the Free // Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. +// /* All rights reserved */ #import diff --git a/Modules/Preferences/Indentation/PCIndentationPrefs.m b/Modules/Preferences/Indentation/PCIndentationPrefs.m index e82e796..0231bb0 100644 --- a/Modules/Preferences/Indentation/PCIndentationPrefs.m +++ b/Modules/Preferences/Indentation/PCIndentationPrefs.m @@ -22,6 +22,7 @@ // You should have received a copy of the GNU General Public // License along with this library; if not, write to the Free // Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. +// /* All rights reserved */ #import @@ -44,55 +45,126 @@ return self; } +- (void) dealloc +{ + [[NSNotificationCenter defaultCenter] removeObserver: self]; + RELEASE(_view); + [super dealloc]; +} + - (void) readPreferences { + NSString *val; + BOOL bVal; + int state; + NSString *spacesDefault = @"2"; + + bVal = [prefs boolForKey: IndentWhenTyping + defaultValue: YES]; + state = bVal ? NSOnState : NSOffState; + [_indentWhenTyping setState:state]; + + bVal = [prefs boolForKey: IndentForOpenCurly + defaultValue: YES]; + state = bVal ? NSOnState : NSOffState; + [_indentForOpenCurly setState:state]; + + bVal = [prefs boolForKey: IndentForCloseCurly + defaultValue: YES]; + state = bVal ? NSOnState : NSOffState; + [_indentForCloseCurly setState: state]; + + bVal = [prefs boolForKey: IndentForSemicolon + defaultValue: NO]; + state = bVal ? NSOnState : NSOffState; + [_indentForSemicolon setState: state]; + + bVal = [prefs boolForKey: IndentForColon + defaultValue: NO]; + state = bVal ? NSOnState : NSOffState; + [_indentForColon setState: state]; + + bVal = [prefs boolForKey: IndentForHash + defaultValue: NO]; + state = bVal ? NSOnState : NSOffState; + [_indentForHash setState: state]; + + bVal = [prefs boolForKey: IndentForReturn + defaultValue: NO]; + state = bVal ? NSOnState : NSOffState; + [_indentForReturn setState: state]; + + bVal = [prefs boolForKey:IndentForColon + defaultValue:NO]; + state = bVal ? NSOnState : NSOffState; + [_indentForColon setState:state]; + + bVal = [prefs boolForKey: IndentForSoloOpenCurly + defaultValue: NO]; + state = bVal ? NSOnState : NSOffState; + [_indentForSoloOpenCurly setState: state]; + + val = [prefs stringForKey: IndentForNumberOfSpaces + defaultValue: spacesDefault]; + if (val) + { + [_indentNumberOfSpaces setStringValue: val]; + } } - (void) setIndentWhenTyping: (id)sender { - /* insert your code here */ + BOOL state = ([sender state] == NSOffState) ? NO : YES; + [prefs setBool: state forKey: IndentWhenTyping notify: YES]; } - (void) setIndentForOpenCurlyBrace: (id)sender { - /* insert your code here */ + BOOL state = ([sender state] == NSOffState) ? NO : YES; + [prefs setBool: state forKey: IndentForOpenCurly notify: YES]; } - (void) setIndentForCloseCurlyBrace: (id)sender { - /* insert your code here */ + BOOL state = ([sender state] == NSOffState) ? NO : YES; + [prefs setBool: state forKey: IndentForCloseCurly notify: YES]; } - (void) setIndentForSemicolon: (id)sender { - /* insert your code here */ + BOOL state = ([sender state] == NSOffState) ? NO : YES; + [prefs setBool: state forKey: IndentForSemicolon notify: YES]; } - (void) setIndentForColon: (id)sender { - /* insert your code here */ + BOOL state = ([sender state] == NSOffState) ? NO : YES; + [prefs setBool: state forKey: IndentForColon notify: YES]; } - (void) setIndentForHash: (id)sender { - /* insert your code here */ + BOOL state = ([sender state] == NSOffState) ? NO : YES; + [prefs setBool: state forKey: IndentForHash notify: YES]; } - (void) setIndentForReturn: (id)sender { - /* insert your code here */ + BOOL state = ([sender state] == NSOffState) ? NO : YES; + [prefs setBool: state forKey: IndentForReturn notify: YES]; } - (void) setIndentForSoloOpenBrace: (id)sender { - /* insert your code here */ + BOOL state = ([sender state] == NSOffState) ? NO : YES; + [prefs setBool: state forKey: IndentForSoloOpenCurly notify: YES]; } - (NSView *) view diff --git a/Modules/Preferences/Indentation/Resources/IndentationPrefs.gorm/objects.gorm b/Modules/Preferences/Indentation/Resources/IndentationPrefs.gorm/objects.gorm index 3c1d1de24c08300cf4d9d984d1b2ef40f46f246e..6fa7f031ea008a16cfef0b4388aafb55b4109624 100644 GIT binary patch delta 280 zcmWm3yGjE=6o6sIaTl~zNSwWCs%#@iY%~@jMZhL;!2~fF;tuR4;th0drB<>Hyk?DGcaZhsbk=l(YNJ}aY%gw_l(Sz3FCw^yzM5r~fN5d{ delta 279 zcmW;GJx&5q6oz4M1}M~0gU-D(gH%pqj*UN1D20g)I7WzZB7r*z14hwAPz!&TaK}?> zJlC&!@>X9~%WAaa%#^17H@kh(okUK(h@WmA-(0`29?}|U+;SJ6 zWnLt>Tl9s4Ik}HxIWJP&lfLNVlj{{WLaM;PGPfF18NcMRpU|O!(|1J?B?itIJ&Ftr z88P*6PAzSAsBYkrLz7|yBgTN52F8rGEmw>KY8$v_q_*5Jjw!`+wXmXXxaDv}+Q1#7 xVaq+EOAP}LjFv5rj6Qy-AO8I6b%dV$dKKZM@PgBU!d6ff8nfVA#CTCE{{cU~W&HpE