Browse Source

Merge remote-tracking branch 'refs/remotes/origin/master'

Dusk 5 months ago
parent
commit
0e076fd4aa
  1. 10
      src/logic/account.c
  2. 12
      src/logic/account.h
  3. 28
      src/logic/prompt.c
  4. 1
      src/logic/prompt.h
  5. 46
      src/logic/timeline.c
  6. 2
      src/logic/timeline.h

10
src/logic/account.c

@ -0,0 +1,10 @@
#include "account.h"
void printAccount(kma_account *account)
{
puts("");
printf("\t%s | %s\n", account->display_name, account->acct);
printf("\tFollowers: %-4d | Following: %-4d\n",
account->followers_count, account->following_count);
puts("");
}

12
src/logic/account.h

@ -0,0 +1,12 @@
#ifndef ACCOUNT_H_
#define ACCOUNT_H_
#include <stdio.h>
#include "kma_account.h"
#include "kma_status.h"
void printAccount(kma_account *account);
#endif // ACCOUNT_H_

28
src/logic/prompt.c

@ -56,6 +56,9 @@ void mainPrompt(kma_conn *conn)
if (timeline_buffer) kma_destroyTL(timeline_buffer);
timeline_buffer = printPublicTL(conn, limit);
}
else if (strcmp(typed, ":profile") == 0) {
//printAccount()
}
else if (
strcmp(typed, ":tlhome") == 0 ||
strcmp(typed, ":tl") == 0
@ -98,10 +101,12 @@ void mainPrompt(kma_conn *conn)
" - ':post' : Enter post composer mode\n"
" - ':tlpub' : Print public TL\n"
" - ':tlhome' or ':tl' : Print home TL\n"
" - [post number shown on tl] : interact with post\n"
" - ':exit' or ':quit' or ':q' : Quit program\n"
" - ':clear' : Clear the prompt screen\n"
" - ':help' : Print this help"
" - ':help' : Print this help\n"
" - ':limit' : Establish the limit of posts shown on the timeline\n"
" - ':profile' : Diplay your account info\n"
"\n"
);
}
@ -111,7 +116,7 @@ void mainPrompt(kma_conn *conn)
printWelcome();
}
else if ((number > 0) && (number < limit)) {
// TIMELINE ACTIONS
{
if (!timeline_buffer) {
puts("Please get a timeline before selecting a post");
@ -121,11 +126,14 @@ void mainPrompt(kma_conn *conn)
char action[32];
uint8_t quit = 0;
puts("Available actions: \n"
"- ':reply' Reply to the selected post\n"
"- ':fav' Favourite the selected post\n"
"- ':reblog' Reblog the selected post\n"
"- ':exit' Return to the main prompt\n"
"- ':reply' : Reply to the selected post\n"
"- ':fav' : Favourite the selected post\n"
"- ':reblog' : Reblog the selected post\n"
"- ':profile' : Display poster account\n"
"- ':exit' : Return to the main prompt\n"
);
puts("Current post:");
printStatus(timeline_buffer[number - 1]);
while (!quit) {
printf("status %d> ", number);
scanf("%s", action);
@ -142,12 +150,16 @@ void mainPrompt(kma_conn *conn)
else if (strcmp(action, ":fav") == 0) {
kma_status *fav_status = kma_favStatus(conn, id);
kma_destroyStatus(fav_status);
quit = 1;
//quit = 1;
}
else if (strcmp(action, ":reblog") == 0) {
kma_status *reblog_status = kma_reblogStatus(conn, id);
kma_destroyStatus(reblog_status);
quit = 1;
//quit = 1;
}
else if (strcmp(action, ":profile") == 0) {
printAccount(timeline_buffer[number - 1]->account);
//quit = 1;
}
else if(strcmp(action, ":exit") == 0) {
quit = 1;

1
src/logic/prompt.h

@ -11,6 +11,7 @@
#include "timeline.h"
#include "post.h"
#include "account.h"
void mainPrompt(kma_conn *conn);

46
src/logic/timeline.c

@ -1,6 +1,7 @@
#include "timeline.h"
kma_status **printPublicTL(kma_conn *conn, int limit){
kma_status **printPublicTL(kma_conn *conn, int limit)
{
kma_status **statuses = kma_getTL(conn,
0, 0, 0,
NULL, NULL, NULL,
@ -10,23 +11,15 @@ kma_status **printPublicTL(kma_conn *conn, int limit){
for (int i = 0; statuses[i] != NULL; i++) {
printf("\033[31;1;4m%d:\n\033[0m", (i + 1));
printf("----- ");
printf("%s | @%s", statuses[i]->account->display_name, statuses[i]->account->acct);
printf(" -----\n");
kma_statusFormat(statuses[i]);
printf("\n%s\n", statuses[i]->content);
printf("\n------------------------------\n");
printf("Reshares: %d | Favourites: %d | \n",
statuses[i]->reblogs_count, statuses[i]->favourites_count);
printf("------------------------------\n\n");
printStatus(statuses[i]);
}
//kma_destroyTL(statuses);
// To implement replying
return statuses;
}
kma_status **printHomeTL(kma_conn *conn, int limit){
kma_status **printHomeTL(kma_conn *conn, int limit)
{
kma_status **statuses = kma_getTL(conn,
0, 0, 0,
NULL, NULL, NULL,
@ -35,20 +28,23 @@ kma_status **printHomeTL(kma_conn *conn, int limit){
);
for (int i = 0; statuses[i] != NULL; i++) {
printf("\033[31;1;4m%d:\n\033[0m", (i + 1));
printf("----- ");
printf("%s | @%s", statuses[i]->account->display_name, statuses[i]->account->acct);
printf(" -----\n");
kma_statusFormat(statuses[i]);
printf("\n%s\n", statuses[i]->content);
printf("\n------------------------------\n");
printf("Reshares: %d | Favourites: %d | \n",
statuses[i]->reblogs_count, statuses[i]->favourites_count);
printf("------------------------------\n\n");
printf("\033[31;1;4m%d>\n\033[0m", (i + 1));
printStatus(statuses[i]);
}
//kma_destroyTL(statuses);
// To implement replying
return statuses;
}
void printStatus(kma_status *status)
{
printf("| ");
printf("%-15s | @%-15s\n", status->account->display_name, status->account->acct);
printf("|----------------------------------------->\n");
kma_statusFormat(status);
printf("%s\n", status->content);
printf("\n|----------------------------------------->\n");
printf("| Reshares: %-3d | Favourites: %-3d > \n",
status->reblogs_count, status->favourites_count);
printf("|----------------------------------------->\n\n");
}

2
src/logic/timeline.h

@ -6,5 +6,5 @@
kma_status **printPublicTL(kma_conn *conn, int limit);
kma_status **printHomeTL(kma_conn *conn, int limit);
void printStatus(kma_status *status);
#endif //LOGIC_TIMELINE_H_

Loading…
Cancel
Save