Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@codemirror/lang-cpp
Advanced tools
@codemirror/lang-cpp is a language support package for CodeMirror 6 that provides syntax highlighting, code folding, and other editing features for C++ code.
Syntax Highlighting
This code sets up a CodeMirror editor with C++ syntax highlighting. The `cpp` function from `@codemirror/lang-cpp` is used to enable C++ language support.
import { cpp } from '@codemirror/lang-cpp';
import { EditorState, EditorView, basicSetup } from '@codemirror/basic-setup';
const state = EditorState.create({
doc: 'int main() { return 0; }',
extensions: [basicSetup, cpp()]
});
const view = new EditorView({
state,
parent: document.body
});
Code Folding
This code sets up a CodeMirror editor with C++ syntax highlighting and code folding capabilities. The `foldGutter` and `foldKeymap` extensions are used to enable code folding.
import { cpp } from '@codemirror/lang-cpp';
import { foldGutter, foldKeymap } from '@codemirror/fold';
import { EditorState, EditorView, basicSetup } from '@codemirror/basic-setup';
const state = EditorState.create({
doc: 'int main() {\n // code\n return 0;\n}',
extensions: [basicSetup, cpp(), foldGutter(), foldKeymap]
});
const view = new EditorView({
state,
parent: document.body
});
Autocomplete
This code sets up a CodeMirror editor with C++ syntax highlighting and autocomplete functionality. The `autocompletion` extension is used to provide autocomplete suggestions.
import { cpp } from '@codemirror/lang-cpp';
import { autocompletion } from '@codemirror/autocomplete';
import { EditorState, EditorView, basicSetup } from '@codemirror/basic-setup';
const state = EditorState.create({
doc: 'int main() {\n // code\n return 0;\n}',
extensions: [basicSetup, cpp(), autocompletion()]
});
const view = new EditorView({
state,
parent: document.body
});
Provides similar functionality for JavaScript code, including syntax highlighting, code folding, and autocomplete. It is part of the CodeMirror 6 ecosystem and offers a comparable set of features for JavaScript.
A powerful code editor that provides syntax highlighting, code folding, and autocomplete for multiple languages, including C++. It is developed by Microsoft and used in Visual Studio Code. Compared to @codemirror/lang-cpp, Monaco Editor offers a more comprehensive set of features but is also heavier.
A standalone code editor that supports syntax highlighting, code folding, and autocomplete for various languages, including C++. Ace is lightweight and easy to integrate but may not offer as many advanced features as CodeMirror 6.
[ WEBSITE | ISSUES | FORUM | CHANGELOG ]
This package implements C++ language support for the CodeMirror code editor.
The project page has more information, a number of examples and the documentation.
This code is released under an MIT license.
We aim to be an inclusive, welcoming community. To make that explicit, we have a code of conduct that applies to communication around the project.
cpp() → LanguageSupport
Language support for C++.
cppLanguage: LezerLanguage
A language provider based on the Lezer C++ parser, extended with highlighting and indentation information.
FAQs
C++ language support for the CodeMirror code editor
We found that @codemirror/lang-cpp demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.