-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathcmd.c
More file actions
46 lines (35 loc) · 1.12 KB
/
Copy pathcmd.c
File metadata and controls
46 lines (35 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <ncurses.h>
#include <string.h>
#include <unistd.h>
#include <pwd.h>
#include <sys/utsname.h>
#include <stdlib.h>
#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <time.h>
#include <sys/time.h>
#include <ctype.h>
#include "types.h"
#include "globals.h"
void cursor_to_cmd() {
// move cursor where it belongs
move(LINES - 2, prompt_length + cursor_pos - cmd_offset);
curs_set(1);
}
void update_cmd() {
attron(COLOR_PAIR(COLOR_WHITE_ON_BLACK));
// Print username, hostname, and current directory path
move(LINES - 2, 0);
clrtoeol();
printw("%s@%s:%s# ", username, unameData.nodename, active_panel->path);
// Calculate max command display length
prompt_length = strlen(username) + strlen(unameData.nodename) + strlen(active_panel->path) + 4; // 5 accounts for '@', ':', '#', and spaces.
int max_cmd_display = COLS - prompt_length;
// Print the visible part of the command, limited to max_cmd_display characters
printw("%.*s", max_cmd_display, cmd + cmd_offset);
cursor_to_cmd();
// Refresh only the changed parts
refresh();
return;
}