Skip to content

Commit

Permalink
Merge pull request #16 from kokseen1/Rewrite
Browse files Browse the repository at this point in the history
Rewrite and restructure logic and code
  • Loading branch information
kokseen1 authored Nov 9, 2022
2 parents 2591c23 + 4ddb9c6 commit e3e71a6
Show file tree
Hide file tree
Showing 108 changed files with 1,637 additions and 51,595 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ obj/
*.exe
*.srt
.vscode/tasks.json
.vscode/c_cpp_properties.json
.vscode/settings.json
*.mp4
8 changes: 3 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,24 @@ CC = gcc

SRC_DIR = src
OBJ_DIR = obj
BIN_DIR = .
BIN_DIR = build

EXE = $(BIN_DIR)/sbubby.exe
SRC = $(wildcard $(SRC_DIR)/*.c)
OBJ = $(SRC:$(SRC_DIR)/%.c=$(OBJ_DIR)/%.o)

LIB_DIR = external/lib
LDLIBS = -lmingw32 -lSDL2main -lSDL2 -lmpv
INCLUDES = -Iexternal/include
INCLUDES = -Iinclude

CPPFLAGS = $(INCLUDES) -MMD -MP
CFLAGS = -Wall
LDFLAGS = $(addprefix -L, $(wildcard $(LIB_DIR)/*))

.PHONY: all clean

all: $(EXE)

$(EXE): $(OBJ) | $(BIN_DIR)
$(CC) -o $@ $(LDFLAGS) $^ $(LDLIBS)
$(CC) -o $@ $^ $(LDLIBS)

$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c | $(OBJ_DIR)
$(CC) -c -o $@ $< $(CPPFLAGS) $(CFLAGS)
Expand Down
93 changes: 47 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,27 @@ Like Vim, Sbubby contains 2 main modes when interacting with the program: NORMAL

`SPACE` - Toggle play/pause

`ESC` - Clear command buffer
`ESC`/`Ctrl c` - Clear command buffer

#### Basic movement
`f` - Toggle fullscreen

#### Movement

`k` - Seek forward

`j` - Seek backward

`K` - Seek forward (small)

`J` - Seek backward (small)

`k` - Seek forward
`n` - Frame step forward

`K` - Seek forward (small)
`N` - Frame step backward

`w` - Seek to next sub
`gg` - Seek to start

`b` - Seek to previous sub
`G` - Seek to end

##### With quantifiers:

Expand All @@ -60,79 +66,73 @@ Like Vim, Sbubby contains 2 main modes when interacting with the program: NORMAL

`i` - Enter INSERT mode

`h` - Set start of sub at current time

`l` - Set end of sub at current time

`o` - Seek to start of sub

`O` - Seek to end of sub
`I` - Enter INSERT mode at start of text

`dd` - Delete sub

##### With quantifiers:

`2o` - Seek to 2s before start of sub
`w` - Seek to next sub

`2O` - Seek to 2s before end of sub
`b` - Seek to start of sub / Seek to previous sub

`2i` - Enter INSERT mode on sub `#2`
`h` - Set start of sub at current time

### INSERT Mode
`l` - Set end of sub at current time

`Ctrl` + `w`/`BACKSPACE` - Delete last word
`e` - Seek to end of sub

`ESC` - Exit INSERT mode
`W` - Switch focus to next sub without seeking

### Ex mode
`B` - Switch focus to previous sub without seeking

Enter Ex mode by entering `:` in NORMAL mode. Press the enter key to execute commands in Ex mode.
`r` - Manually reload subtitles

`:{pos}` - Seek to `pos` seconds of the video; `:100` seeks to `00:01:40.000`, etc.
`dd` - Delete sub

`:w` - Save the current subtitle as `<video.mp4>.srt`
##### With quantifiers:

`:q` - Quit without saving
`2i` - Enter INSERT mode on sub `#2`

`:wq` - Save the current subtitle and quit
`3w` - Seek `3` subs forward

### Additional controls
### INSERT Mode

#### Movement
`Ctrl p` - Toggle play/pause

`s` - Frame step forward
`LEFT`/`RIGHT` - Move cursor between characters

`S` - Frame step backward
`Ctrl LEFT`/`Ctrl RIGHT` - Move cursor between words

`gg` - Seek to start
`HOME` - Move cursor to start

`W` - Switch focus to next sub without seeking
`END` - Move cursor to end

`B` - Switch focus to previous sub without seeking
`Ctrl w`/`Ctrl Backspace` - Delete word before cursor

#### Subtitling
`Ctrl Delete` - Delete word after cursor

`Hj` - Shift start of sub 0.1s backward
`ESC`/`Ctrl c` - Exit INSERT mode

`Hk` - Shift start of sub 0.1s forward
### Ex mode

`Lj` - Shift end of sub 0.1s backward
Enter Ex mode by entering `:` in NORMAL mode. Press `ENTER` to execute commands in Ex mode.

`Lk` - Shift end of sub 0.1s forward
`:w` - Save current subtitles as `<video.mp4>.srt`

##### With quantifiers:
`:q` - Quit without saving

`3Hj` - Shift start of sub 0.3s backward
`:wq` - Save current subtitles and quit

`2Lk` - Shift end of sub 0.2s forward
`ESC`/`Ctrl c` - Clear command buffer

## Building from source

### Prerequisites

- MinGW-w64
- SDL2-devel
- libmpv
- Make
- DLL search path contains binaries found in `external/bin`
- DLL search path contains:
- `libmpv-2.dll`
- `SDL2.dll`

### Steps

Expand All @@ -145,12 +145,13 @@ git clone https://github.com/kokseen1/Sbubby
2. Build

```
cd Sbubby
make
make clean
```

3. Run

```
sbubby.exe
.\build\sbubby.exe <video.mp4>
```
Binary file removed external/bin/SDL2.dll
Binary file not shown.
Binary file removed external/bin/libmpv-2.dll
Binary file not shown.
Loading

0 comments on commit e3e71a6

Please # to comment.