aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c37
1 files changed, 36 insertions, 1 deletions
diff --git a/main.c b/main.c
index d3359d0..41efec3 100644
--- a/main.c
+++ b/main.c
@@ -11,6 +11,7 @@
#include <unistd.h>
#include <term.h>
+#include <wordexp.h>
#include "wind.h"
@@ -240,7 +241,7 @@ int main(int argc, char* argv[]){
if( !tabed ) {
contact* found = NULL;
move(LINES-1,0);
- readline_n();
+ readline_n("> ", "");
int r = findContactFromName(msg_win_str, &found);
if( r == 0 ) {
@@ -263,6 +264,40 @@ int main(int argc, char* argv[]){
resize();
}
break;
+ case 'e':
+ if( tabed ) {
+ contact* selected = getContactSelected();
+ readline_n("Edit contact | Name : ", selected->name);
+ strcpy(selected->name, msg_win_str);
+ readline_n("Edit contact | Display name : ", selected->display_name);
+ strcpy(selected->display_name, msg_win_str);
+ writeContactList(config.CONTACT_FILENAME);
+ showContactListW();
+ }
+ break;
+ case 'a':
+ if( !tabed ) {
+ contact newContact = {"", "", "", 0, NULL};
+ readline_n("New contact | Name : ", "");
+ strcpy(newContact.name, msg_win_str);
+ readline_n("New contact | Display name : ", "");
+ strcpy(newContact.display_name, msg_win_str);
+ readline_n("New contact | Number : ", "");
+ strcpy(newContact.number, msg_win_str);
+
+ addContact(&newContact);
+
+ if( *config.CONTACT_FILENAME == '\0' ) {
+ wordexp_t p;
+ r = wordexp("~/.mesms_contacts.csv", &p, 0);
+ if( r == 0 && p.we_wordc > 0 ) {
+ strcpy(config.CONTACT_FILENAME, p.we_wordv[0]);
+ }
+ }
+ writeContactList(config.CONTACT_FILENAME);
+ showContactListW();
+ }
+ break;
case 'i':
case 's': {
char* number = NULL;