Skip to content

Toggle comment for current line via CMD + / #241

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 37 commits into from
Apr 25, 2024
Merged
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
b8acee0
add random comment to test git syncing with package
Sophiahooley Apr 14, 2024
9cecfa8
add key down event monitor
Sophiahooley Apr 14, 2024
7882267
create basic function to understand functionality of keyDown
Sophiahooley Apr 15, 2024
fca0329
edit basic function to include viewDidLoad call
Sophiahooley Apr 15, 2024
0787b98
changes to basic function
Sophiahooley Apr 15, 2024
614ce7e
add local monitoring functionality
Sophiahooley Apr 15, 2024
6879299
debug output for characters ignoring modifiers
Sophiahooley Apr 15, 2024
85e7c18
add check to see if cmd / has been pressed
Sophiahooley Apr 15, 2024
802815d
change function output to match what it is doing
Sophiahooley Apr 15, 2024
fd1ace9
print out cursor positions when cmd/ pressed
Sophiahooley Apr 15, 2024
8698fb7
include debug statement for what string is when cmd/ is pressed
Sophiahooley Apr 15, 2024
87511ba
attempt to insert text when cmd/ pressed
Sophiahooley Apr 15, 2024
2167053
insert text at beginning of line
Sophiahooley Apr 15, 2024
8d40d08
print out current cursor line
Sophiahooley Apr 16, 2024
1c5e334
fix line indexing
Sophiahooley Apr 16, 2024
f231eca
fix indexing again
Sophiahooley Apr 16, 2024
b692a31
insert comment at beginning of line using line char index
Sophiahooley Apr 16, 2024
507247b
add debug to see if code reaches inner if statement
Sophiahooley Apr 16, 2024
ecfc976
use lineCommentString instead of hardcoded string for comment
Sophiahooley Apr 17, 2024
412c327
add space after comment insert
Sophiahooley Apr 18, 2024
6c86617
print lineInfo data
Sophiahooley Apr 18, 2024
555ed63
print line info line fragments
Sophiahooley Apr 18, 2024
2498247
print line info
Sophiahooley Apr 19, 2024
a23c0aa
get substring of current line
Sophiahooley Apr 19, 2024
1a5870c
toggle commenting
Sophiahooley Apr 19, 2024
0b288ad
finish single line implementation, clean up code, add case for no lin…
Sophiahooley Apr 19, 2024
0eeddec
rollback
Sophiahooley Apr 19, 2024
acbbec5
make requested changes from PR (more comments, delete debug line)
Sophiahooley Apr 21, 2024
3bf438a
refactor keyboard shortcuts logic, more changes requested from PR
Sophiahooley Apr 21, 2024
664e375
fix swiftlint errors
Sophiahooley Apr 21, 2024
723761c
get rid of extra line
Sophiahooley Apr 21, 2024
acb3bb8
fix more lint issues
Sophiahooley Apr 22, 2024
a10b2f7
make new file for keyboard shortcuts
Sophiahooley Apr 22, 2024
e520e6c
more linter errors fixed
Sophiahooley Apr 22, 2024
4a4306e
lastfix of lint errors
Sophiahooley Apr 22, 2024
fab9079
get rid of blank line
Sophiahooley Apr 22, 2024
15a6e33
Merge branch 'main' into main
FastestMolasses Apr 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
toggle commenting
  • Loading branch information
Sophiahooley committed Apr 19, 2024
commit 1a5870c9b57810ce07c9d3d96cae6a4b5cfc346c
10 changes: 8 additions & 2 deletions Sources/CodeEditSourceEditor/Controller/TextViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,15 @@ public class TextViewController: NSViewController {
let languageCommentStr = language.lineCommentString
let lengthOfCommentStr = languageCommentStr.count
let range = NSRange(location: lineFirstCharIndex, length: lengthOfCommentStr)
// equal to length of language's comment string
let firstCharsInLine = textView.textStorage.substring(from: range)
print(textView.textStorage.substring(from: range))
// let currentLinePosition = textView.layoutManager.lineStorage.getLine(atIndex: lineFirstCharIndex)
textView.replaceCharacters(in:NSRange(location: lineFirstCharIndex, length: 0), with: languageCommentStr + " ")
// toggle comments depending on if comment already there
if firstCharsInLine == languageCommentStr {
textView.replaceCharacters(in:NSRange(location: lineFirstCharIndex, length: lengthOfCommentStr), with: "")
} else {
textView.replaceCharacters(in:NSRange(location: lineFirstCharIndex, length: 0), with: languageCommentStr + " ")
}
}
}
}
Expand Down