clipboard support
This commit is contained in:
		
							
								
								
									
										4
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -30,6 +30,4 @@
 | 
			
		||||
# Executables
 | 
			
		||||
*.exe
 | 
			
		||||
*.out
 | 
			
		||||
*.app
 | 
			
		||||
 | 
			
		||||
builds/
 | 
			
		||||
*.app
 | 
			
		||||
							
								
								
									
										28
									
								
								.vscode/tasks.json
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										28
									
								
								.vscode/tasks.json
									
									
									
									
										vendored
									
									
								
							@@ -1,28 +0,0 @@
 | 
			
		||||
{
 | 
			
		||||
    "tasks": [
 | 
			
		||||
        {
 | 
			
		||||
            "type": "cppbuild",
 | 
			
		||||
            "label": "C/C++: g++ build active file",
 | 
			
		||||
            "command": "/usr/bin/g++",
 | 
			
		||||
            "args": [
 | 
			
		||||
                "-fdiagnostics-color=always",
 | 
			
		||||
                "-g",
 | 
			
		||||
                "${file}",
 | 
			
		||||
                "-o",
 | 
			
		||||
                "${fileDirname}/${fileBasenameNoExtension}"
 | 
			
		||||
            ],
 | 
			
		||||
            "options": {
 | 
			
		||||
                "cwd": "${fileDirname}"
 | 
			
		||||
            },
 | 
			
		||||
            "problemMatcher": [
 | 
			
		||||
                "$gcc"
 | 
			
		||||
            ],
 | 
			
		||||
            "group": {
 | 
			
		||||
                "kind": "build",
 | 
			
		||||
                "isDefault": true
 | 
			
		||||
            },
 | 
			
		||||
            "detail": "Task generated by Debugger."
 | 
			
		||||
        }
 | 
			
		||||
    ],
 | 
			
		||||
    "version": "2.0.0"
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										6
									
								
								CMakeLists.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								CMakeLists.txt
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,6 @@
 | 
			
		||||
cmake_minimum_required(VERSION 2.8)
 | 
			
		||||
project(owo)
 | 
			
		||||
add_executable(owo owo.cpp)
 | 
			
		||||
add_subdirectory(clip)
 | 
			
		||||
target_link_libraries(owo clip)
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										5
									
								
								PKGBUILD
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								PKGBUILD
									
									
									
									
									
								
							@@ -12,10 +12,11 @@ md5sums=('SKIP')
 | 
			
		||||
 | 
			
		||||
build() {
 | 
			
		||||
    cd "$srcdir/term-owo-cpp"
 | 
			
		||||
    g++ -o owo owo.cpp
 | 
			
		||||
    make . -B build
 | 
			
		||||
    cd build && make
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
package() {
 | 
			
		||||
    cd "$srcdir/term-owo-cpp"
 | 
			
		||||
    cd "$srcdir/term-owo-cpp/build"
 | 
			
		||||
    install -Dm755 owo "$pkgdir/usr/bin/owo"
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										1
									
								
								clip
									
									
									
									
									
										Submodule
									
								
							
							
								
								
								
								
								
							
						
						
									
										1
									
								
								clip
									
									
									
									
									
										Submodule
									
								
							 Submodule clip added at 4e9eeea929
									
								
							
							
								
								
									
										12
									
								
								owo.cpp
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								owo.cpp
									
									
									
									
									
								
							@@ -2,6 +2,7 @@
 | 
			
		||||
#include <regex>
 | 
			
		||||
#include <string>
 | 
			
		||||
#include <fstream>
 | 
			
		||||
#include "clip/clip.h"
 | 
			
		||||
using namespace std;
 | 
			
		||||
 | 
			
		||||
string replacements[6][2] = {
 | 
			
		||||
@@ -29,12 +30,16 @@ int help() {
 | 
			
		||||
    cout << "Options:" << endl;
 | 
			
		||||
    cout << "  -p  Read from stdin" << endl;
 | 
			
		||||
    cout << "  -h  Show this help message" << endl;
 | 
			
		||||
    cout << "  -f  Read from file" << endl;
 | 
			
		||||
    cout << "  -o  Write to file" << endl;
 | 
			
		||||
    cout << "  -c  Copy to clipboard" << endl;
 | 
			
		||||
    cout << "  text  Text to convert" << endl;
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int main(int argc, char *argv[]) {
 | 
			
		||||
    string input, inputfile, outputfile;
 | 
			
		||||
    bool _stdin = false;
 | 
			
		||||
    bool _stdin = false, clipboard = false;
 | 
			
		||||
 | 
			
		||||
    if (argc < 2) {
 | 
			
		||||
        cout << owo("No text provided") << endl << endl;
 | 
			
		||||
@@ -55,6 +60,8 @@ int main(int argc, char *argv[]) {
 | 
			
		||||
            return help();
 | 
			
		||||
        } else if (i == argc-1) {
 | 
			
		||||
            input = string(argv[i]);
 | 
			
		||||
        } else if (string(argv[i]) == "-c") {
 | 
			
		||||
            clipboard = true;
 | 
			
		||||
        } else {
 | 
			
		||||
            cout << owo("Invalid argument: " + string(argv[i])) << endl << endl;
 | 
			
		||||
            help();
 | 
			
		||||
@@ -109,6 +116,9 @@ int main(int argc, char *argv[]) {
 | 
			
		||||
    } else if (input != "") {
 | 
			
		||||
        if (outputfile != "") {
 | 
			
		||||
            *output << owo(input) << endl;
 | 
			
		||||
        } else if (clipboard) {
 | 
			
		||||
            clip::set_text(owo(input));
 | 
			
		||||
            cout << owo("Copied to clipboard") << endl;
 | 
			
		||||
        } else {
 | 
			
		||||
            cout << owo(input) << endl;
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user