summary refs log blame commit diff stats
path: root/CHANGELOG
blob: 8078305d286e23040a70d7d7dbc4250b2c50deea (plain) (tree)
1
2
3
4
5
6
7
8



                                                                             

                                                   











                                                                           




                                                                           

                                                            
             
















                                                              
This log only documents changes between stable versions.

From 1.2 on, odd minor version numbers (1.3, 1.5, 1.7,..) are assigned to the
fresh git snapshots while stable versions will have even minor numbers.

1.2 -> 1.2.1:
* Fixed yy/pp bug when yanking multiple directories

1.1.2 -> 1.2:
* !!! Changed the default configuration directory to ~/.config/ranger !!!
* Removed "Console Modes", each old mode is now a simple command
* Disabled file previews by default if ranger is used by root
* Allow to jump to specific help sections by typing two numbers, e.g. 13?
* Added keys: da, dr, ya, yr for adding and removing files from copy buffer
* Added keys: gl and gL to resolve links, see 11?
* Added key: pL to create a relative symlink
* Added %<LETTER> and %<N><LETTER> macros for the console, see 33?
* Fixed ansi codes for colors in the pager
* Use the file ~/.mime.types for mime type detection
* Several clean-ups and fixes

1.1.1 -> 1.1.2:
* Fix crash when using scrollwheel to scroll down in some cases
* The command "ranger dir1 dir2 ..." opens multiple directories in tabs
* Removed pydoc html documentation by default, re-create it with "make doc"
* Minor fixes

1.1.0 -> 1.1.1:
* New install script, "setup.py"
* New flag for running programs: "w" (waits for enter press)
* Minor fixes

1.0.4 -> 1.1.0:
* Added a man page
* Tab support
* Improved directory loading performance
* Commands are definable in ~/.ranger/commands.py
* Case insensitive sorting (type zs)
* Better UTF support
* Possibility to turn off previews (zp and zP)
* Changing options with :set (e.g. :set column_ratios=1,2,3,4)
* Ask for confirmation when using :delete
* New invocation flag: --fail-unless-cd
* New hotkeys, commands, options.
* New syntax for ~/.ranger/keys.py
* Several user contributions
* And tons of general improvements

NOTE: The syntax for configuration is still subject to change.
9d3b9fc ^
cac0ea07 ^
6bad38c2 ^
89d3b9fc ^
a85ba5e2 ^
fef15b93 ^
a85ba5e2 ^

fef15b93 ^




89d3b9fc ^
6bad38c2 ^
89d3b9fc ^





cac0ea07 ^
89d3b9fc ^


279737ba ^

89d3b9fc ^


a85ba5e2 ^
89d3b9fc ^


cac0ea07 ^
89d3b9fc ^

6bad38c2 ^
89d3b9fc ^
a85ba5e2 ^
6c9cbc44 ^
89d3b9fc ^
a85ba5e2 ^
6bad38c2 ^
cac0ea07 ^
89d3b9fc ^




cac0ea07 ^
89d3b9fc ^


279737ba ^

89d3b9fc ^




a85ba5e2 ^
89d3b9fc ^





279737ba ^

89d3b9fc ^








6bad38c2 ^
89d3b9fc ^


b02b52d8 ^
89d3b9fc ^

6bad38c2 ^
89d3b9fc ^

b02b52d8 ^
89d3b9fc ^



b02b52d8 ^
89d3b9fc ^

6bad38c2 ^
89d3b9fc ^





279737ba ^

89d3b9fc ^

6bad38c2 ^
89d3b9fc ^
a85ba5e2 ^
89d3b9fc ^
eb5b04df ^
6bad38c2 ^
a85ba5e2 ^
6bad38c2 ^
89d3b9fc ^



a85ba5e2 ^
89d3b9fc ^







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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
  

                                                     
  


















                                                                       






                              
                                                            
 
                        
 






                                                                
                                      
 
                                       



                             
                                      






                                 
                                                

                                                    
                    
                                 
 
                     
 
                     
                                                  
                                                            
                            
 
                     
                                                          
                                                
                                                    



                                      
             
 




                                                    
                    

     
                                                                

                                                              
                                                       

                                  
                     
                                 
 
                     
                                                   
                                                
                                                                  
                                   
 
                            



                                      
                     

     
                                         



                             
                                                        




                                  
                                                            







                                 
                        

                                                                       
                                            
                     
                                
                                    
                                                               


                                
                                            
                          
 




                                         
                                            
                 
 
                      
                               
                               
                                               
                           
                                                                           
 


                                                          
                                       






                                  
/*
 * prof_autocomplete.c
 *
 * Copyright (C) 2012 James Booth <boothj5@gmail.com>
 *
 * This file is part of Profanity.
 *
 * Profanity is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Profanity is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Profanity.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#include <stdlib.h>
#include <string.h>

#include "prof_autocomplete.h"

struct p_autocomplete_t {
    GSList *items;
    GSList *last_found;
    gchar *search_str;
};

static gchar * _search_from(PAutocomplete ac, GSList *curr);

PAutocomplete
p_autocomplete_new(void)
{
    PAutocomplete new = malloc(sizeof(struct p_autocomplete_t));
    new->items = NULL;
    new->last_found = NULL;
    new->search_str = NULL;

    return new;
}

void
p_autocomplete_clear(PAutocomplete ac)
{
    g_slist_free_full(ac->items, free);
    ac->items = NULL;

    p_autocomplete_reset(ac);
}

void
p_autocomplete_reset(PAutocomplete ac)
{
    ac->last_found = NULL;
    if (ac->search_str != NULL) {
        free(ac->search_str);
        ac->search_str = NULL;
    }
}

gboolean
p_autocomplete_add(PAutocomplete ac, void *item)
{
    if (ac->items == NULL) {
        ac->items = g_slist_append(ac->items, item);
        return TRUE;
    } else {
        GSList *curr = ac->items;

        while(curr) {

            // insert
            if (g_strcmp0(curr->data, item) > 0) {
                ac->items = g_slist_insert_before(ac->items,
                    curr, item);
                return TRUE;

            // update
            } else if (g_strcmp0(curr->data, item) == 0) {
                // only update if data different
                if (strcmp(curr->data, item) != 0) {
                    free(curr->data);
                    curr->data = item;
                    return TRUE;
                } else {
                    return FALSE;
                }
            }

            curr = g_slist_next(curr);
        }

        // hit end, append
        ac->items = g_slist_append(ac->items, item);

        return TRUE;
    }
}

gboolean
p_autocomplete_remove(PAutocomplete ac, const char * const item)
{
    // reset last found if it points to the item to be removed
    if (ac->last_found != NULL)
        if (g_strcmp0(ac->last_found->data, item) == 0)
            ac->last_found = NULL;

    if (!ac->items) {
        return FALSE;
    } else {
        GSList *curr = ac->items;

        while(curr) {
            if (g_strcmp0(curr->data, item) == 0) {
                void *current_item = curr->data;
                ac->items = g_slist_remove(ac->items, curr->data);
                free(current_item);

                return TRUE;
            }

            curr = g_slist_next(curr);
        }

        return FALSE;
    }
}

GSList *
p_autocomplete_get_list(PAutocomplete ac)
{
    GSList *copy = NULL;
    GSList *curr = ac->items;

    while(curr) {
        copy = g_slist_append(copy, strdup(curr->data));
        curr = g_slist_next(curr);
    }

    return copy;
}

gchar *
p_autocomplete_complete(PAutocomplete ac, gchar *search_str)
{
    gchar *found = NULL;

    // no items to search
    if (!ac->items)
        return NULL;

    // first search attempt
    if (ac->last_found == NULL) {
        ac->search_str =
            (gchar *) malloc((strlen(search_str) + 1) * sizeof(gchar));
        strcpy(ac->search_str, search_str);

        found = _search_from(ac, ac->items);
        return found;

    // subsequent search attempt
    } else {
        // search from here+1 tp end
        found = _search_from(ac, g_slist_next(ac->last_found));
        if (found != NULL)
            return found;

        // search from beginning
        found = _search_from(ac, ac->items);
        if (found != NULL)
            return found;

        // we found nothing, reset search
        p_autocomplete_reset(ac);
        return NULL;
    }
}

static gchar *
_search_from(PAutocomplete ac, GSList *curr)
{
    while(curr) {

        // match found
        if (strncmp(curr->data,
                ac->search_str,
                strlen(ac->search_str)) == 0) {
            gchar *result =
                (gchar *) malloc((strlen(curr->data) + 1) * sizeof(gchar));

            // set pointer to last found
            ac->last_found = curr;

            // return the string, must be free'd by caller
            strcpy(result, curr->data);
            return result;
        }

        curr = g_slist_next(curr);
    }

    return NULL;
}